Namespaces
Variants
Actions

Archived:Create a list of platform threads in PySymbian

Jump to: navigation, search
Archived.png
Aquivado: 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

Compatibility
Platform(s): S60 3rd Edition

Article
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
processList.append(p)
 
for i in processList:
i.start()
 
def run(self):
e32.ao_yield()
self.pop()
 
principal = Principal()
principal.start()
This page was last modified on 8 May 2013, at 09:27.
181 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved