473,385 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Cross Thread Event Handling

Hi all,

I am working on a mesaging system at the moment which
currently uses at least two threads, one the main client
interface, and the second (or more) providing a
network/message listener.

The project works and is happily providing the required
functionality, but the users of the system are unhappy
about having to handle concurrency issues (Mainly to do
with UI updates) in their code, due to the fact that when
an event is thrown from the listener (e.g. You have a new
message from the server, or the network is now unavailable
etc.) to the client interface and upwards, the event is on
the same thread as the listner and not the client.

Is there some way of throwing events to a different thread
within an application? Or some way of listening for these
messages on the same thread as the client thread? Or can I
pass a callback pointer to the new thread that it can call?

Any help would be great.

Cheers

Rob P
Nov 15 '05 #1
1 2176
Hi Rob,

You might do something like this in event implementation.

if (InvokeRequired())
Invoke(the same event)
else
{
do the UI code
}

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"Rob P" <an*******@discussions.microsoft.com> wrote in message
news:09****************************@phx.gbl...
Hi all,

I am working on a mesaging system at the moment which
currently uses at least two threads, one the main client
interface, and the second (or more) providing a
network/message listener.

The project works and is happily providing the required
functionality, but the users of the system are unhappy
about having to handle concurrency issues (Mainly to do
with UI updates) in their code, due to the fact that when
an event is thrown from the listener (e.g. You have a new
message from the server, or the network is now unavailable
etc.) to the client interface and upwards, the event is on
the same thread as the listner and not the client.

Is there some way of throwing events to a different thread
within an application? Or some way of listening for these
messages on the same thread as the client thread? Or can I
pass a callback pointer to the new thread that it can call?

Any help would be great.

Cheers

Rob P

Nov 15 '05 #2

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

Similar topics

31
by: AlexeiOst | last post by:
Everywhere in documentation there are recommendations to use threads from thread pooling for relatively short tasks. As I understand, fetching a page or multiple pages (sometimes up to 50 but not...
4
by: John Fereira | last post by:
So, one of the limitations of multipart-form handling is that when an <input type="file" ..> tag is used it will bring up a window which allows a user to select a file for upload but won't allow...
7
by: Droopy | last post by:
Hi, I don't understand why sometimes, a loop running in a thread takes much more time than usual. I have a thread that must call each 20 ms a C++ unmanaged function. I made a C++ managed...
16
by: droopytoon | last post by:
Hi, I start a new thread (previous one was "thread timing") because I have isolated my problem. It has nothing to do with calling unmanaged C++ code (I removed it in a test application). I...
8
by: Pieter | last post by:
Hi, I'm having some weird problem using the BackGroundWorker in an Outlook (2003) Add-In, with VB.NET 2005: I'm using the BackGroundWorker to get the info of some mailitems, and after each item...
18
by: Dave Booker | last post by:
I have a Thread making a callback to a Form function that alters Form data. Of course, the debugger is telling me, "Cross-thread operation not valid: Control 'FormTest' accessed from a thread other...
10
by: Daniel | last post by:
Hi guys I have a form with my gui on, just some list boxes. And a class that handles incoming data. i want to, on receiving data, update my gui. However even though i have an instance...
4
by: Paul Cheetham | last post by:
Hi, I have a couple of classes that I am using to read a swipe-card reader attached to the serial port (c# VS 2005 Pro). I have a SerialComm class which actaully reads the serial port, and a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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 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.