473,804 Members | 3,497 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Delegate and Thread Problem

I have a Delegate based Project that contain classes whose purpose is to
instantiate objects of another Project (or Library) using Delegates. I have
a client application that uses this Delegate based project to call library
method asynchronously. Delegate based project returns the control to the
client immediately and so the client can perorm other tasks. Every thing
works fine but soon as i close the client application, the back ground
processing also ends. In other words, the Delegate based project and library
Project also stops. why is that? How can i call method using delegate that
continue the processing even if the client application terminates.

I can work around this scenario by creating threads and calling method in
thread. My client application calls the method of a project named
ThreadCreator. The ThreadCreator in turn creates a new thread and calls the
appropriate library method in that thread. Now even if the client
application terminates, my processing continues. The problem with this
approach is that my ThreadCreator project cant call method that takes
parameters. The work aournd here is to go for statefull object, but my
library objects are all stateless. How can i call method using thread that
takes parameters ?

Please answer for both scenario
Regards,
Irfan
Nov 16 '05 #1
0 982

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
2465
by: Paul | last post by:
Hi, I have the following code in a winform: .... private delegate void DownloadDelegate(string src, string dest); .... private void DownloadFile(string src, string dest) { WebClient wc = new WebClient();
0
1473
by: Paul Tomlinson | last post by:
Morning all. Let me describe my problem. Main thread creates child objects and threads and starts them Timer on the main thread (which only gets activated after the child threads have started) periodically calls a function Refresh(). This refresh function runs on its own thread and queries our database for new jobs. For each job found this timer invokes a delegate on one of the child thread objects. I then get the error "Cannot call...
4
1875
by: pz0071 | last post by:
G'day, I think I got my head around using delegates, particularily when updating the user interface from another thread. I got it all sussed, just not 100% sure on the correct syntax for calling the delegate. Is this.Invoke(delUpdateUI, args); Same as delUpdateUI(i);
0
2504
by: Wavemaker | last post by:
One of the things I've struggled with from time to time is handling events raised on different threads. For example, an object could be listening to events from one or more objects running in different threads besides itself. There is a concern for thread safety. There are various ways of dealing with this. One way is to make the class thread safe by putting in locks. But another way is to stream the events from the various threads into a...
6
15161
by: Valerie Hough | last post by:
I'm not entirely sure what the difference is between these two approaches. In order to avoid reentrant code, I was using Control.BeginInvoke in my UI to cause an asynchronous activity to be done on the UI's message loop. I began to get System.ExecutionEngineException errors so (on the theory of do something different if what you're doing isn't working) I switched to using delegate.BeginInvoke with the appropriate EndInvoke and the problem...
1
1170
by: Eric Newton | last post by:
Given the following code, Public class ProgressFormManager Public Sub BeginInvoke(ByVal method As , ByVal args() As Object) Dim asyncCallback As New System.Threading.WaitCallback(method) System.Threading.ThreadPool.QueueUserWorkItem(asyncCallback, args) End Sub .... End Class
9
1973
by: Terry Olsen | last post by:
I'm running an asynchronous Socket. In the ReceiveCallback method, I need to append what is received to a textbox on the main form. I have this code: Private Sub ToChatWindow(ByVal msg As String) txtChat.AppendText(msg) End Sub I've never used a delegate or invoke before and I'm rather confused on the topic. Hope someone can help.
5
1681
by: Richard MSL | last post by:
I have an application in managed C++, and a method in C# that I call. But now I want to add the ability to tell the C# method a specific method in my C++ assembly to call back to. For example, to have the C++ call a sort routine in C#, and send it a compare method, which the C## would call back to. I know that within C# pointing to methods is done with delegates, but is it possible between C++ and C#? Is there an example of this somewhere...
5
1968
by: jecheney | last post by:
Hi, another thread, Debug_Console is a listbox control on my main form, i created the delegate to avoid the cross threading error. Now the strange thing is, when i call the method from my other thread, the entry string is added to the listbox, but it also throws an exception after the string is added. I cant work out why. The exception is: =========================
0
9704
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9571
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10318
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10302
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10069
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7608
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5505
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5639
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4277
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.