Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Archived:Create a list of platform threads in PySymbian

From Wiki
Jump to: navigation, search

Archived.pngAquivado: Este artigo foi arquivado, pois o conteúdo não é mais considerado relevante para se criar soluções comerciais atuais. Se você achar que este artigo ainda é importante, inclua o template {{ForArchiveReview|escreva a sua justificativa}}.

All PySymbian articles have been archived. PySymbian is no longer maintained by Nokia and is not guaranteed to work on more recent Symbian devices. It is not possible to submit apps to Nokia Store.

This code snippet lists open threads on Symbian using PySymbian. The threads can be used to manipulate asyncronous processes.

Article Metadata
Tested with
Devices(s): Nokia N95
Keywords: threading
Created: User:Jonesambrosi (29 Aug 2009)
Last edited: hamishwillee (08 May 2013)


Modules used

import sys
from appuifw import *
import os
import e32
import threading
import random

Defining Thread

In this code the thread class is create. The class sum numbers and store in result list after run

class process(threading.Thread):
value = 0
tx = 0
def sum(self):
x = 1
for i in range(1, self.value):
x = x + i
return x
def run(self):
e32.ao_yield() # Define above normal process
x = self.sum()
processResult.append({ 'thread' : self.tx, 'result': x })
print "%s %s" % (self.tx,x)

Main process

The main process create threads class with random number and start process with it thread.

processList = [] 
processResult = []
class Principal(threading.Thread):
def pop(self):
for i in range(200):
p = process()
p.value = random.randint(1, 10000)
p.tx = i
for i in processList:
def run(self):
principal = Principal()

Version Hint

Windows Phone: [[Category:Windows Phone]]
[[Category:Windows Phone 7.5]]
[[Category:Windows Phone 8]]

Nokia Asha: [[Category:Nokia Asha]]
[[Category:Nokia Asha Platform 1.0]]

Series 40: [[Category:Series 40]]
[[Category:Series 40 1st Edition]] [[Category:Series 40 2nd Edition]]
[[Category:Series 40 3rd Edition (initial release)]] [[Category:Series 40 3rd Edition FP1]] [[Category:Series 40 3rd Edition FP2]]
[[Category:Series 40 5th Edition (initial release)]] [[Category:Series 40 5th Edition FP1]]
[[Category:Series 40 6th Edition (initial release)]] [[Category:Series 40 6th Edition FP1]] [[Category:Series 40 Developer Platform 1.0]] [[Category:Series 40 Developer Platform 1.1]] [[Category:Series 40 Developer Platform 2.0]]

Symbian: [[Category:Symbian]]
[[Category:S60 1st Edition]] [[Category:S60 2nd Edition (initial release)]] [[Category:S60 2nd Edition FP1]] [[Category:S60 2nd Edition FP2]] [[Category:S60 2nd Edition FP3]]
[[Category:S60 3rd Edition (initial release)]] [[Category:S60 3rd Edition FP1]] [[Category:S60 3rd Edition FP2]]
[[Category:S60 5th Edition]]
[[Category:Symbian^3]] [[Category:Symbian Anna]] [[Category:Nokia Belle]]

This page was last modified on 8 May 2013, at 06:27.
66 page views in the last 30 days.