×
Namespaces

Variants
Actions
Revision as of 06:27, 8 May 2013 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Archived:Create a list of platform threads in PySymbian

From Nokia Developer 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
CompatibilityArticle
Keywords: threading
Created: User:Jonesambrosi (29 Aug 2009)
Last edited: hamishwillee (08 May 2013)

Contents

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
processList.append(p)
 
for i in processList:
i.start()
 
def run(self):
e32.ao_yield()
self.pop()
 
principal = Principal()
principal.start()

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.
50 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×