473,806 Members | 2,655 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Raising Asynchronous Events from Components

I have a multi-threaded class that I am creating that needs needs to raise
events when certain asynchronous events occur. I would always like the
events to be raised to the primary UI thread of any application that is using
my component. I can't just call raiseevent from the thread that catches the
asynchronous data. (In this case from a serial port). This is because I
have a separate thread reading from the serial device. How can I marshall
the call such the event is raised on the primary UI thread?

My only solution right now is to use a Form Timer in the class and
repeatedly poll the thread to see if any events should be raised. Is there a
better way?
Nov 21 '05 #1
2 1574
This sounds very promising. Thanks for the info. I couldn't access the
project you said you were attaching. Can you try to attach it again. I
would really like to see it.

Thanks,
John

"Charles Law" wrote:
Hi John

Have a look at ISynchronizeInv oke. The attached project shows how you can
use it to do what you are asking.

HTH

Charles
"TrtnJohn" <Tr******@discu ssions.microsof t.com> wrote in message
news:D7******** *************** ***********@mic rosoft.com...
I have a multi-threaded class that I am creating that needs needs to raise
events when certain asynchronous events occur. I would always like the
events to be raised to the primary UI thread of any application that is
using
my component. I can't just call raiseevent from the thread that catches
the
asynchronous data. (In this case from a serial port). This is because I
have a separate thread reading from the serial device. How can I marshall
the call such the event is raised on the primary UI thread?

My only solution right now is to use a Form Timer in the class and
repeatedly poll the thread to see if any events should be raised. Is
there a
better way?


Nov 21 '05 #2
Doh, I am using IE to view the board. I was hoping for a link to download
from :(
"Charles Law" wrote:
I have attached it again but with a txt extension in case your newsreader is
blocking zip files. Save and rename it with a zip extension and away you go.

Charles
"TrtnJohn" <Tr******@discu ssions.microsof t.com> wrote in message
news:0F******** *************** ***********@mic rosoft.com...
This sounds very promising. Thanks for the info. I couldn't access the
project you said you were attaching. Can you try to attach it again. I
would really like to see it.

Thanks,
John

"Charles Law" wrote:
Hi John

Have a look at ISynchronizeInv oke. The attached project shows how you can
use it to do what you are asking.

HTH

Charles
"TrtnJohn" <Tr******@discu ssions.microsof t.com> wrote in message
news:D7******** *************** ***********@mic rosoft.com...
>I have a multi-threaded class that I am creating that needs needs to
>raise
> events when certain asynchronous events occur. I would always like the
> events to be raised to the primary UI thread of any application that is
> using
> my component. I can't just call raiseevent from the thread that
> catches
> the
> asynchronous data. (In this case from a serial port). This is because
> I
> have a separate thread reading from the serial device. How can I
> marshall
> the call such the event is raised on the primary UI thread?
>
> My only solution right now is to use a Form Timer in the class and
> repeatedly poll the thread to see if any events should be raised. Is
> there a
> better way?


Nov 21 '05 #3

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

Similar topics

1
1563
by: john bailo | last post by:
Suppose I am writing a program that has to execute as series of steps, but at several of the steps, I want to wait for external events to occur. For example ( and this relates to another of my posts ), say I want to execute a method, then wait for a flag file. Ok, someone suggested using FileSystemWatcher. So then, say I do that, how do I make an internal event halt execution on the main method, wait for the event
3
5135
by: David | last post by:
Hi, Ive been trying to work this out for the past 2 days now and im not getting anywhere fast. The problem i have is that i am using Asynchronous sockets to create a Socket Client library. When i try to connect to a server that doesnt exist it raises a "Connection forcibly rejected by the resmote host" SocketException.
6
2887
by: Dan | last post by:
I've created a pocketpc app which has a startup form containing a listview. The form creates an object which in turn creates a System.Threading.Timer. It keeps track of the Timer state using a TimerState object similar to the example in the System.Threading.Timer documentation. The method which handles the timer events, among other things, periodically calls a method in this TimerState object which raises an event to the startup form,...
1
2843
by: Natalia DeBow | last post by:
Hi, I am working on a Windows-based client-server application. I am involved in the development of the remote client modules. I am using asynchronous delegates to obtain information from remote server and display this info on the UI. From doing some research, I know that the way my implementation works today is not thread-safe, because essentially my worker thread updates the UI, which is BAD. So, here I am trying to figure out how...
4
17271
by: rawCoder | last post by:
Hi all, How Can You Raise Events Asynchronously ? Now for the details ... I want to do inter modular communication using events in such a way that the contributing modules need not maintain the reference to any module.
7
2446
by: cider123 | last post by:
I'm coding a project using the following article as reference: http://www.codeproject.com/csharp/DynamicPluginManager.asp In this type of project, plugins are loaded dynamically into a Plugin Manager. Your main application then hooks into the Plugin Manager. What I'm trying to figure out is how to impliment some form of raising
2
1784
by: VBTricks.de.vu Webmaster | last post by:
Hello everybody, I need to write a HTTP client capable of downloading files using the HTTP protocoll. But downloading is one of my problems. I'm new to VB.net and I know there's a framework offering a solution for almost every problem. But for me it's a bit complex. So what I need: I need a way to download files asynchronously. In VB6 I solved this problem with a self-written component using sockets. As of the large
4
1599
by: Dave A | last post by:
I am developing a somewhat complex component at the moment and coincidently I am also reading the Framework Design Guidelines book. After reading the section about event raising I have re-written the way my component raises events to follow the Framework Design Guides verbatim; ie (object sender, EventArgs (or some subclass there of) e). The thing that was not explained is why should I need to cast the sender to 'object' when I know...
2
1700
by: Gman | last post by:
Hi, I have created a usercontrol, a grid control essentially. Within it I have a class: clsGridRecord. I have coded the events such that when a user clicks on the grid, say, the events occur on the parent form. This is fine. The problem occurs when I want to raise an event for a user clicking on one of the clsRecords which are on the grid. So I've placed: Public Event GridRecordClicked(ByVal rec As clsGridRecord,
0
10371
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
10373
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
10111
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...
0
9192
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7650
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
6877
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4330
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
2
3852
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3010
bsmnconsultancy
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.