PC Review


Reply
Thread Tools Rate Thread

Asyncronous Threading Code Block?

 
 
Pug Fugly
Guest
Posts: n/a
 
      12th May 2004
I have been using asynchronous threading to handle the button actions
on my form (the ones that need to make database calls anyways). I am
curious if anyone has found a way to make the calls more generic? Is
it possible to structure the code so that you don't have to create the
delegate, BeginAction(), EndAction(), and ActionCallback() functions
for every single action that I want to handle? Especially since the
only thing different about them is the main calling method name.

Thanks,
Slavisa
 
Reply With Quote
 
 
 
 
AlexS
Guest
Posts: n/a
 
      12th May 2004
Hi, Pug

You can consider to create one delegate, which will be passed parameter
defining function to perform. Then all event handlers will call same
delegate and delegate itself will decide what do to.

HTH
Alex

"Pug Fugly" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I have been using asynchronous threading to handle the button actions
> on my form (the ones that need to make database calls anyways). I am
> curious if anyone has found a way to make the calls more generic? Is
> it possible to structure the code so that you don't have to create the
> delegate, BeginAction(), EndAction(), and ActionCallback() functions
> for every single action that I want to handle? Especially since the
> only thing different about them is the main calling method name.
>
> Thanks,
> Slavisa



 
Reply With Quote
 
Tom Shelton
Guest
Posts: n/a
 
      12th May 2004
In article <(E-Mail Removed)>, Pug Fugly wrote:
> I have been using asynchronous threading to handle the button actions
> on my form (the ones that need to make database calls anyways). I am
> curious if anyone has found a way to make the calls more generic? Is
> it possible to structure the code so that you don't have to create the
> delegate, BeginAction(), EndAction(), and ActionCallback() functions
> for every single action that I want to handle? Especially since the
> only thing different about them is the main calling method name.
>
> Thanks,
> Slavisa


You could build a class to encapsulate this. It could take a delegate
and invoke it asyncrounously, and then notify you when done via events.
Actually, in the next version of .NET there is a BackgroundWorker
component that basically does this for you - but it wouldn't be to
difficult to write a component that would handle this for you.

--
Tom Shelton [MVP]
 
Reply With Quote
 
Jay B. Harlow [MVP - Outlook]
Guest
Posts: n/a
 
      13th May 2004
Slavisa,
As Tom suggested, .NET 2.0 will include the BackgroundWorker class.

The following article discusses how this class works.

http://www.mikedub.net/windowsformsr...es/000009.html

The article also has links to a series of articles on multithreading that
may or may not help.

Hope this helps
Jay

"Pug Fugly" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I have been using asynchronous threading to handle the button actions
> on my form (the ones that need to make database calls anyways). I am
> curious if anyone has found a way to make the calls more generic? Is
> it possible to structure the code so that you don't have to create the
> delegate, BeginAction(), EndAction(), and ActionCallback() functions
> for every single action that I want to handle? Especially since the
> only thing different about them is the main calling method name.
>
> Thanks,
> Slavisa



 
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
Threading question - ensure execution of a block of code kpg Microsoft VB .NET 1 6th May 2010 06:55 AM
Threading.Monitor.Enter that doesn't /quite/ block the thread Jon Brunson Microsoft Dot NET Compact Framework 18 7th Apr 2006 12:04 PM
Need Threading code for animation Dixon Microsoft VB .NET 0 26th Jan 2006 12:46 PM
Need Threading code for animation Dixon Microsoft VB .NET 0 26th Jan 2006 12:46 PM
Wrox C# Threading Handbook Code Dirc Microsoft C# .NET 0 21st Aug 2003 11:40 AM


Features
 

Advertising
 

Newsgroups
 


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