Hello,
I was wondering if callback delegates, called in response to a event,
are executed in their own thread. I was suspecting the OS might spawn
a new thread and have the delegate execute in that thread but having
written a small sample application this does not seem to be happening.
I'm writing an application that will be receiving messages from a
Tibco RV messaging bus and from MSMQ and that will also have to handle
those messages (elaborate them and take appropriate actions). I was
worried that if no threads are created to execute my C# delegates in
response to an event (a new Tibco message or a new MSMQ message), in
periods of heavy messaging and message handling/elaboration, messages
might start to just gather and in the end might start to get dropped.
If callback methods (delegates) were indeed executed in a separate
thread this situation would probably never occur, not being so (or at
least it seems) I'm facing the possibility of having to write a
multithreaded application ... which I would very much like to avoid.
Any suggestion???
Bob Rock 4 5616
When you invoke an event the delegates are called on the same thread as
raised the event (which means they're called sequentially).
Ken
"Bob Rock" <an************ ***@yahoo.com> wrote in message
news:98******** *************** ***@posting.goo gle.com... Hello,
I was wondering if callback delegates, called in response to a event, are executed in their own thread. I was suspecting the OS might spawn a new thread and have the delegate execute in that thread but having written a small sample application this does not seem to be happening.
I'm writing an application that will be receiving messages from a Tibco RV messaging bus and from MSMQ and that will also have to handle those messages (elaborate them and take appropriate actions). I was worried that if no threads are created to execute my C# delegates in response to an event (a new Tibco message or a new MSMQ message), in periods of heavy messaging and message handling/elaboration, messages might start to just gather and in the end might start to get dropped.
If callback methods (delegates) were indeed executed in a separate thread this situation would probably never occur, not being so (or at least it seems) I'm facing the possibility of having to write a multithreaded application ... which I would very much like to avoid. Any suggestion???
Bob Rock
If the callback method is not invoked asynchronously, you can still invoke
your delegate asynchronously. Have the callback method do something like
myDelgate.Begin Invoke(....). The myDelegate() will execute on a thread from
the pool, and the event handler will return immediately. There's no reason
one delegate can't invoke another.
good luck
kevin aubuchon
"Ken Kolda" <ke*******@elli emae-nospamplease.co m> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. .. When you invoke an event the delegates are called on the same thread as raised the event (which means they're called sequentially).
Ken
"Bob Rock" <an************ ***@yahoo.com> wrote in message news:98******** *************** ***@posting.goo gle.com... Hello,
I was wondering if callback delegates, called in response to a event, are executed in their own thread. I was suspecting the OS might spawn a new thread and have the delegate execute in that thread but having written a small sample application this does not seem to be happening.
I'm writing an application that will be receiving messages from a Tibco RV messaging bus and from MSMQ and that will also have to handle those messages (elaborate them and take appropriate actions). I was worried that if no threads are created to execute my C# delegates in response to an event (a new Tibco message or a new MSMQ message), in periods of heavy messaging and message handling/elaboration, messages might start to just gather and in the end might start to get dropped.
If callback methods (delegates) were indeed executed in a separate thread this situation would probably never occur, not being so (or at least it seems) I'm facing the possibility of having to write a multithreaded application ... which I would very much like to avoid. Any suggestion???
Bob Rock
> If the callback method is not invoked asynchronously, you can still invoke your delegate asynchronously. Have the callback method do something like myDelgate.Begin Invoke(....). The myDelegate() will execute on a thread from the pool, and the event handler will return immediately. There's no reason one delegate can't invoke another.
good luck kevin aubuchon
Thank you Kevin,
the problem is that if the application is heavely busy it may take
sometime for your callback function to be called and thus your
delegate to be fired.
Anyone have any other idea???
Is there anything that makes the OS implicitly spawn a new thread to
do that something???
Bob Rock
> the problem is that if the application is heavely busy it may take sometime for your callback function to be called and thus your delegate to be fired.
Anyone have any other idea??? Is there anything that makes the OS implicitly spawn a new thread to do that something???
You can start your own thread, raise its priority level, and deliver the
events on that thread. The thread can block on an event waiting for a msg to
arrive. The input would add the msg to a list and set the event (waking up
the thread). The thread pulls msgs off the list and invokes the delegate
synchronously (ctl.Invoke) until there are no msgs left on the list.
You'll have to provide locks for thread safety (add/remove from the list).
Other then that it ought to be straightforward . This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Paul E Collins |
last post by:
I use Process.Start to open a URL in the user's browser.
When I call the function normally, it works fine. However, when I call it
from a separate thread, I get an error: "The requested section was not
present in the activation context".
The only C# newsgroup thread dealing with this error blames it on a Main
function that is missing the attribute - but my Main function
has this attribute.
|
by: Bob Rock |
last post by:
Hello,
exploring more and more the .NET framework I've seen that threads are
often employed by the framework, for example in:
- callback methods on timers
- async operations (async receives on message queues, etc.)
Wanting to avoid executing the event handler code in a different
thread is there a *standard* way (something like a pattern) to
|
by: MuZZy |
last post by:
Hi,
Could someone pls help me here:
If i use async sockets in the separate thread like this:
void ThreadFunction()
{
.....
1. MySocket.BeginAccept(AsyncCallBack(OnConnectRequest), MySocket);
|
by: Kevin |
last post by:
In a newsgroup thread from Jan 8, 2003 between Barry Holsinger and the
VBDotNet Team, please review this excerpt:
"You understood my problem completely. Your sample code provides a
really
elegant way to inject CrLf into the input stream, which effectively
unblocks
the ReadLine method. Last night, I had finally got the
WriteConsoleInput
|
by: cyberco |
last post by:
I want to import a long list of modules in a separate thread to speed
things up. How can I make the modules imported in that separate thread
accessible outside the method?
===========================
import os
# import rest in a separate thread
def importRest():
import audio
| |
by: Jaret Brower |
last post by:
I'm trying to parse html that resides locally by using the HtmlDocument class
and unfortunately you can only get an instance of an HtmlDocument through the
WebBrowser control.
Some of the html files I want to parse are quite large so I want to get the
HtmlDocument in a separate thread. But for some reason, whenever I move the
code to navigate the WebBrowser to a separate thread the DocumentCompleted
event is never fired. When I step...
|
by: titan nyquist |
last post by:
I have a class with data and methods that use it. Everything is
contained perfectly
THE PROBLEM: A separate thread has to call a method in the current
instantiation of this class. There is only ever ONE instantiation of
this class, and this outside method in a separate thread has to access
it.
How do i do this?
|
by: stumorgan |
last post by:
Basically what I have is a form with a graph on it which graphs data
that I'm reading from a USB device at 100 Hz (every 10ms). I have a
thread reading and parsing the data from the USB, but when it comes
time to draw that data on the graph the work is handled on the main UI
thread through a callback delegate since the form owns the graph
control. Is there a way I can have a separate thread own the graph
control and handle the drawing so...
|
by: Silgd1 |
last post by:
Hi All.....
I am using netbeans 6.1 to create a web application(visual web jsf pages). I have a heavy task I need to run, so I run the task in a separate thread which is started from a button_action. Once the button is clicked, it sets visible a woodstock component progress bar(Indeterminate) to show the heavy task is running. The problem I am having is try to get the progress bar to "disappear" once the heavy task has completed and the...
|
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...
|
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,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
|
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,...
|
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...
|
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...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |