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 3 1040
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" <sl*****@msn.com> wrote in message
news:d8*************************@posting.google.co m... 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
In article <d8*************************@posting.google.com> , 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]
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" <sl*****@msn.com> wrote in message
news:d8*************************@posting.google.co m... 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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Nathan |
last post by:
On my .NET web project I am trying to make an asyncronous call to a function
using IAsyncResult. The function will process for about a 1/2 hour. before it
completes, the process abruptly ends as...
|
by: Ayende Rahien |
last post by:
The following first throws the nasty exception dialog, and only then show me
the message.
Is there a way to avoid this?
This occur both inside & outside VS.
public class Test
{
private...
|
by: Tom |
last post by:
I've googled, and read, and stripped out code, and rewritten code, and
still can't get a System.Threading.Timer to work. (I hereby publicly
admit that I'm a failure here...) Could someone please...
|
by: il RicercatoreSbadato |
last post by:
title: asyncronous Socket and EndAccept()
question: hi to all, I am working with a server that uses the sockets in a
asyncronous way. When I want to STOP the server I do the following:
-...
|
by: Bob |
last post by:
Okay, I've done this for years but now I'm going to question it just because
this idea has been at the back of my head since I started using DotNet...
My WinForms app queries a database every 60...
| |
by: Michael Kennedy |
last post by:
Hi,
I have been looking into the claim that the keyword lock is not safe
when exceptions are possible. That lead me to try the following code,
which I think has uncovered a serious error in the...
|
by: OJ |
last post by:
Hi,
I have written a small C# 2.0 DLL which acts as a client to a Socket
based server over the internet. I have written both synchronous and
asynchronous methods to connect, send, and receive data...
|
by: cgwalters |
last post by:
Hi,
I've recently been working on an application which does quite a bit
of searching through large data structures and string matching, and I
was thinking that it would help to put some of this...
|
by: LoneTiger |
last post by:
Hi everyone,
I've got a smaller problem which I can't get around of. I've seen some quite usefull answers around and was hoing someone might be able to help.
What I'm working on is a...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |