Re: Background thread with lower priority



If a GC occurs, all threads in the process are suspended. Doesn't matter
what priority any of the threads are.

Are you sure it is a GC that's causing the non-responsiveness?


--
Chris Tacke
OpenNETCF Consulting
Managed Code in the Embedded World
www.opennetcf.com
--


"Jeffry van de Vuurst" <jeffry.cwrmobility@xxxxxxxxxxxxxxxxx> wrote in
message news:eNdHtCTHHHA.4712@xxxxxxxxxxxxxxxxxxxxxxx
Hi,

I have a CF 2.0 app that uses 2 background threads. 1 for polling for a
network connection and 1 for performing a background sync.

First I used the OpenNETCF BackgroundWorker for this purpose. However,
when performing a background sync the UI became unresponsive. Now I
changed it to a regular thead using:
Thread backgroundSyncThread = new Thread(DoBackgroundSync);
backgroundSyncThread.Priority = ThreadPriority.Lowest;
backgroundSyncThread.IsBackground = true;
backgroundSyncThread.Start();

However, I read here
http://www.danielmoth.com/Blog/2004/08/threads-and-threadpriority-with-net.html,
that chaging the priority of threads may be risky because garbage
collection could run on the low priority thread.

It's an article from August 2004 but does mention CF 2.0 beta 1. Does this
still apply? And if so, what are other ways to make sure that the
(potentially long) running background thread doesn't freeze the UI? Is
doing a Thread.Sleep(0) from the worker thread effective? I've read
different stories about the effectiveness of Thread.Sleep(0)...

Thanks,

--
Jeffry van de Vuurst
CWR Mobility
www.cwrmobility.com
--




.



Relevant Pages

  • Re: Background thread with lower priority
    ... matter since that thread is running whatever its priority. ... running on lower priority have unexpected side effects (like mentioned ... a network connection and 1 for performing a background sync. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Background thread with lower priority
    ... It's not the GC that causes the non-responsiveness. ... the non-responsiveness is caused by running my background sync on a thread ... That's the reason I started creating my own thread and setting the priority ... lower priority have unexpected side effects ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Background thread with lower priority
    ... Priority to BelowNormal, it wouldn't get any time because the UI still has a ... Jeffry van de Vuurst ... the background sync takes about 20 seconds. ... Running it at a lower priority would allow the UI to get quantum before ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Background thread with lower priority
    ... Jeffry van de Vuurst ... the Priority to BelowNormal, it wouldn't get any time because the UI ... the background sync takes about 20 seconds. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Background thread with lower priority
    ... *any* thread in the system with a higher priority than you and it is in the ... Jeffry van de Vuurst ... the background sync takes about 20 seconds. ... Running it at a lower priority would allow the UI to get quantum ...
    (microsoft.public.dotnet.framework.compactframework)