PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Compact Framework Re: Threading across abstraction layers

Reply

Re: Threading across abstraction layers

 
Thread Tools Rate Thread
Old 08-07-2003, 03:31 AM   #1
Chris Tacke, eMVP
Guest
 
Posts: n/a
Default Re: Threading across abstraction layers


Why not implement a delegate/event that the main thread can implement a
handler on and have the thread raise it when it's done? Othe options would
be a Mutex or other synchronization event.

-Chris


"Ian Williamson" <bmcpeake@nospam.shaw.ca> wrote in message
news:0f8c01c344f2$2b2d2860$a001280a@phx.gbl...
> Greetings,
>
> You can tell I am nearing the end of my project as I am
> now posting all my little bugaboos that I do not have an
> answer for.
>
> I am using Merge Replication and I want to pop-up a
> window with an animated GIF that executes during the span
> of the call to Replicate the data.
>
> Now since I cannot query the state of the thread in CE,
> how am I going to know when the call to the Replicate
> method is done?
>
> Right now, I will be doing this sort of thing within my
> presentation layer:
>
> private void UpdateData()
> {
> MyDataReplicator myDataReplicator = new MyDataReplicator
> ();
> myPopup popup = new myPopup(); // form with animated GIF
> Thread thread = new Thread(new ThreadStart
> (myDataReplicator.Replicate()));
> thread.Start();
> popup.Show();
> while (true)
> {
> popup.Update(); // animate next frame of GIF
> sleep(1000);
> *** something here to check state of "thread" to see
> if it has completed execution - if true, break
> }
> popup.Dispose();
> myDataReplicator.Displose();
>
>
> Also, what are the best practices for disposing of a
> thread like this once it has completed?
>
> Note that I do not want to use Invoke to update my GUI
> from the delegate thread as it is in my Data Tier and
> making such a callback would really muck up my
> abstraction model.
>
>
> Cheers, Ian Williamson
>
>



  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off