PC Review


Reply
Thread Tools Rate Thread

Asynchronous methods, Invoke

 
 
Christian Westerlund
Guest
Posts: n/a
 
      17th Mar 2004
Hi!

From one of my worker threads I want to update the UI so I
use myControl.Invoke but I want the worker thread to continue work after
that but with Invoke the worker thread blocks until the method returns.
I know of BeginInvoke but that isn't available in .NET CF.

Is there another method I can use to solve this problem.

/Christian
 
Reply With Quote
 
 
 
 
Daniel Moth
Guest
Posts: n/a
 
      17th Mar 2004
At the point where you wish to call BeginInvoke, use the ThreadPool to
callback one of your methods and in that method call Control.Invoke...

Cheers
Daniel


"Christian Westerlund" <(E-Mail Removed)> wrote in message
news:etRQFy$(E-Mail Removed)...
> Hi!
>
> From one of my worker threads I want to update the UI so I
> use myControl.Invoke but I want the worker thread to continue work after
> that but with Invoke the worker thread blocks until the method returns.
> I know of BeginInvoke but that isn't available in .NET CF.
>
> Is there another method I can use to solve this problem.
>
> /Christian



 
Reply With Quote
 
Christian Westerlund
Guest
Posts: n/a
 
      17th Mar 2004
Thanks!

I'll look into it, hope it works!

/Christian

Daniel Moth wrote:

> At the point where you wish to call BeginInvoke, use the ThreadPool to
> callback one of your methods and in that method call Control.Invoke...
>
> Cheers
> Daniel
>
>
> "Christian Westerlund" <(E-Mail Removed)> wrote in message
> news:etRQFy$(E-Mail Removed)...
>
>>Hi!
>>
>> From one of my worker threads I want to update the UI so I
>>use myControl.Invoke but I want the worker thread to continue work after
>>that but with Invoke the worker thread blocks until the method returns.
>>I know of BeginInvoke but that isn't available in .NET CF.
>>
>>Is there another method I can use to solve this problem.
>>
>>/Christian

>
>
>

 
Reply With Quote
 
Christian Westerlund
Guest
Posts: n/a
 
      17th Mar 2004
Ok, I got it to work with ThreadPool.QueueUserWorkItem but it seems to
be a little too much to create another thread just to run a single
method. Aren't there any other function which one can use for this purpose?

/Christian

Christian Westerlund wrote:
> Thanks!
>
> I'll look into it, hope it works!
>
> /Christian
>
> Daniel Moth wrote:
>
>> At the point where you wish to call BeginInvoke, use the ThreadPool to
>> callback one of your methods and in that method call Control.Invoke...
>>
>> Cheers
>> Daniel
>>
>>
>> "Christian Westerlund" <(E-Mail Removed)> wrote in message
>> news:etRQFy$(E-Mail Removed)...
>>
>>> Hi!
>>>
>>> From one of my worker threads I want to update the UI so I
>>> use myControl.Invoke but I want the worker thread to continue work after
>>> that but with Invoke the worker thread blocks until the method returns.
>>> I know of BeginInvoke but that isn't available in .NET CF.
>>>
>>> Is there another method I can use to solve this problem.
>>>
>>> /Christian

>>
>>
>>
>>

 
Reply With Quote
 
Daniel Moth
Guest
Posts: n/a
 
      17th Mar 2004
Hi Christian

BeginInvoke on the desktop framework does the same thing (i.e. utilise a
thread from the ThreadPool)... If the framework works as advertised you
should find that the pool reuses threads rather than creating new ones each
time... Note that unlike the desktop framework, the number of threads on CF
is not limited to 25... Anyway I use this technique with no problems...

Alternatively you may wish to check out
http://www.develop.com/compactframework/ and in particular the "UI Safe
Invoker" under samples... Never used it myself but looks promising...

Cheers
Daniel


"Christian Westerlund" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Ok, I got it to work with ThreadPool.QueueUserWorkItem but it seems to
> be a little too much to create another thread just to run a single
> method. Aren't there any other function which one can use for this

purpose?
>
> /Christian
>
> Christian Westerlund wrote:
> > Thanks!
> >
> > I'll look into it, hope it works!
> >
> > /Christian
> >
> > Daniel Moth wrote:
> >
> >> At the point where you wish to call BeginInvoke, use the ThreadPool to
> >> callback one of your methods and in that method call Control.Invoke...
> >>
> >> Cheers
> >> Daniel
> >>
> >>
> >> "Christian Westerlund" <(E-Mail Removed)> wrote in

message
> >> news:etRQFy$(E-Mail Removed)...
> >>
> >>> Hi!
> >>>
> >>> From one of my worker threads I want to update the UI so I
> >>> use myControl.Invoke but I want the worker thread to continue work

after
> >>> that but with Invoke the worker thread blocks until the method

returns.
> >>> I know of BeginInvoke but that isn't available in .NET CF.
> >>>
> >>> Is there another method I can use to solve this problem.
> >>>
> >>> /Christian
> >>
> >>
> >>
> >>



 
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
Create my own asynchronous BeginXXXX methods and EndXXXX methods Varangian Microsoft C# .NET 2 15th May 2008 09:46 PM
Asynchronous Invoke and the UI thread (using delegates) =?Utf-8?B?YnJpc2Vycw==?= Microsoft VB .NET 7 6th Mar 2006 06:45 PM
Asynchronous Methods Brian Corcoran Microsoft C# .NET 0 5th Aug 2005 05:13 PM
ListView.Invoke deadlocks within Asynchronous Delegate Mike V Microsoft Dot NET Framework 2 1st Apr 2004 06:51 PM
Asynchronous web methods =?Utf-8?B?aHM=?= Microsoft Dot NET 2 8th Mar 2004 08:53 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:38 PM.