views:

121

answers:

2

Im making a windows mobile app and i was wondering how i go about doing background processing (ie. threading)

Is there a special way to do this with windows mobile?

From your answers and comments looks like the best way is to use the .NET Threading classes. I think i expected too much here...

+1  A: 

You need to distinguish between processes and threads. If you create a new thread within a .NET process, it will use the same process... but that's not the same as using the original thread.

Please give more detail about the "built in .NET class" that "doesn't seem to work properly" - my suspicion is that you're either not using it properly or have incorrect expectations. In my experience, using background threads in .NET CF projects works fine.

Jon Skeet
Yeh, my wording for this question is pretty bad...Pretty much, i want my app to do some things (ie. read a file) in the background instead of slowing down the UI, if that makes more sense?
d1k_is
@d1k_is: Yes, so you use a background thread as you would in normal .NET. You'll need to marshal back to the UI thread to update it. Now, please edit your question to say what you mean by the normal .NET class not working properly... ideally with code.
Jon Skeet
+1  A: 

Using the code below in a console app I get two different thread id's (and by debugging it's clear that they run simultaneously):

    static void Main(string[] args)
    {
        new Thread(new ThreadStart(ThreadMethod)).Start();
        Console.WriteLine("Thread " + Thread.CurrentThread.ManagedThreadId + " has control");
        Console.ReadLine();
    }

    static void ThreadMethod()
    {
        Console.WriteLine("Thread " + Thread.CurrentThread.ManagedThreadId + " has control");
    }

Even on the emulator. You could see if this is the case for your emulator.

deltreme