PC Review


Reply
 
 
=?Utf-8?B?TmlsbGU=?=
Guest
Posts: n/a
 
      22nd Nov 2004
Hi!
I have a serious problem with what appears to be a deadlock in .NET cf. It
occures when I invoke Invalidate on a control from a thread other than the
main thread when the main thread is busy (i.e. displaying a form).

I have a situation similiar to this:

public class MyForm : System.Windows.Forms.Form
{

// ...

private void MyThreadedMethod()
{
while(true)
{
myLabel.Text = "..."; // This hangs the application if the main
thread is busy.
System.Threading.Thread.Sleep(1000);
}
}

// ...

}

How can I avoid this?

Thanks in advance!
Nille
 
Reply With Quote
 
 
 
 
Peter Foot [MVP]
Guest
Posts: n/a
 
      22nd Nov 2004
You should always use Control.Invoke to update UI elements from a worker
thread. There are some limitations in the Compact Framework's Control.Invoke
method but these are not impossible to workaround - See an example here on
Daniel's blog:-
http://www.danielmoth.com/Blog/2004/...d-full-fx.html

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

"Nille" <(E-Mail Removed)> wrote in message
news:52C98140-A034-4AEF-A724-(E-Mail Removed)...
> Hi!
> I have a serious problem with what appears to be a deadlock in .NET cf. It
> occures when I invoke Invalidate on a control from a thread other than the
> main thread when the main thread is busy (i.e. displaying a form).
>
> I have a situation similiar to this:
>
> public class MyForm : System.Windows.Forms.Form
> {
>
> // ...
>
> private void MyThreadedMethod()
> {
> while(true)
> {
> myLabel.Text = "..."; // This hangs the application if the main
> thread is busy.
> System.Threading.Thread.Sleep(1000);
> }
> }
>
> // ...
>
> }
>
> How can I avoid this?
>
> Thanks in advance!
> Nille



 
Reply With Quote
 
Daniel Moth
Guest
Posts: n/a
 
      22nd Nov 2004
http://www.danielmoth.com/Blog/2004/...d-full-fx.html

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


"Nille" <(E-Mail Removed)> wrote in message
news:52C98140-A034-4AEF-A724-(E-Mail Removed)...
> Hi!
> I have a serious problem with what appears to be a deadlock in .NET cf. It
> occures when I invoke Invalidate on a control from a thread other than the
> main thread when the main thread is busy (i.e. displaying a form).
>
> I have a situation similiar to this:
>
> public class MyForm : System.Windows.Forms.Form
> {
>
> // ...
>
> private void MyThreadedMethod()
> {
> while(true)
> {
> myLabel.Text = "..."; // This hangs the application if the main
> thread is busy.
> System.Threading.Thread.Sleep(1000);
> }
> }
>
> // ...
>
> }
>
> How can I avoid this?
>
> Thanks in advance!
> Nille



 
Reply With Quote
 
=?Utf-8?B?TmlsbGU=?=
Guest
Posts: n/a
 
      22nd Nov 2004
Thank you very, very much for responding! I hope this will solve my problem
(haven't been able to try it yet)!

Nille

"Daniel Moth" wrote:

> http://www.danielmoth.com/Blog/2004/...d-full-fx.html
>
> Cheers
> Daniel
> --
> http://www.danielmoth.com/Blog/
>
>
> "Nille" <(E-Mail Removed)> wrote in message
> news:52C98140-A034-4AEF-A724-(E-Mail Removed)...
> > Hi!
> > I have a serious problem with what appears to be a deadlock in .NET cf. It
> > occures when I invoke Invalidate on a control from a thread other than the
> > main thread when the main thread is busy (i.e. displaying a form).
> >
> > I have a situation similiar to this:
> >
> > public class MyForm : System.Windows.Forms.Form
> > {
> >
> > // ...
> >
> > private void MyThreadedMethod()
> > {
> > while(true)
> > {
> > myLabel.Text = "..."; // This hangs the application if the main
> > thread is busy.
> > System.Threading.Thread.Sleep(1000);
> > }
> > }
> >
> > // ...
> >
> > }
> >
> > How can I avoid this?
> >
> > Thanks in advance!
> > Nille

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
deadlock Tony Johansson Microsoft C# .NET 2 11th May 2010 10:46 AM
NT Loader Deadlock Marko Becirevic Microsoft C# .NET 4 6th Jul 2005 03:51 PM
Re: Possible deadlock condition kdwalker Microsoft Windows 2000 0 5th Feb 2004 05:03 PM
ASP.NET deadlock Kevin Jackson Microsoft ASP .NET 1 5th Feb 2004 03:59 AM
Possible deadlock condition Marc Rosenthal Microsoft Windows 2000 Networking 1 3rd Jul 2003 07:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:33 PM.