473,804 Members | 2,164 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"Posting" to GUI Thread from Background Thread

I'm working on an app which uses a background thread to read data from
a socket.

At the moment I'm doing something a bit "naughty" -- I'm firing an
event after reading from the socket, and this event gets picked up by
an event handler in the GUI thread, without "synchroniz ing" with this
GUI thread.

How can I "synchroniz e" threads in .NET?
Nov 15 '05 #1
3 9407
MSDN Mag (Feb 03) issue has an excellent article on threads for responsive
UI -
http://msdn.microsoft.com/msdnmag/is...g/default.aspx

Hope that helps.
SBC
"C# Learner" <cs****@learner .here> wrote in message
news:3d******** *************** *********@4ax.c om...
I'm working on an app which uses a background thread to read data from
a socket.

At the moment I'm doing something a bit "naughty" -- I'm firing an
event after reading from the socket, and this event gets picked up by
an event handler in the GUI thread, without "synchroniz ing" with this
GUI thread.

How can I "synchroniz e" threads in .NET?

Nov 15 '05 #2
C# Learner <cs****@learner .here> wrote:
I'm working on an app which uses a background thread to read data from
a socket.

At the moment I'm doing something a bit "naughty" -- I'm firing an
event after reading from the socket, and this event gets picked up by
an event handler in the GUI thread, without "synchroniz ing" with this
GUI thread.

How can I "synchroniz e" threads in .NET?


Use Control.Invoke to run a delegate in the GUI thread associated with
a specific control.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #3
C# Learner <cs****@learner .here> wrote:

<snip>

Thanks guys.
Nov 15 '05 #4

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

Similar topics

33
3035
by: Steven Bethard | last post by:
I feel like this has probably been answered before, but I couldn't find something quite like it in the archives. Feel free to point me somewhere if you know where this has already been answered. I have a list in a particular order that I want to split into two lists: the list of every nth item, and the list of remaining items. It's important to maintain the original order in both lists. So the first list is simple:
3
2982
by: Barry Pearson | last post by:
I'm posting here because this is associated with the behaviour of a floated element. It has similarities to the IE 6 (on Windows) "peekaboo" bug, and I suspect was written by the same coder having a bad-hair day. http://www.barry.pearson.name/test/ie6_bug.htm "Peekaboo" causes text in a "floatholder" to fail to be rendered. "My" bug (which I am willing to sell for lots of money) causes part of a floated box to suddenly disappear when a...
3
1284
by: John | last post by:
Hi, I have a class which on instantiation creates a background thread to do its processing in. The class exposes a number of events that the application subscribes to so that data can be reported. How can I make it so that when my class calls an event (a callback) it does so with the application's main thread and not with the background thread?
5
10338
by: Mike Logan | last post by:
I used WSDL.exe to generate a client side web proxy for a web service, called the web service, got the results but an array returned by the web service is not in the results. However if I use "Add Web Reference" for the same service the same function works appropriately. Here is the client proxy generated from WSDL.exe <System.Web.Services.Protocols.SoapDocumentMethodAttribute("capeconnect:AppSec:AppSecPortType#getApplicationUsers",
6
1662
by: tony | last post by:
Is it possible to use the post method to send a form from PHP without having to put the form in a html page? <form action="https://www.mysite.com/cgi/incoming.php" method="post"> <input type="hidden" name="data01" value="12"> <input type="hidden" name="data02" value="rejected"> <input type="hidden" name="star" value="sirius"> <input type="image" src="https://www.mysite.com/grid001/image1.gif" border="0" name="submit" alt="send data">...
3
1637
by: jpa770 | last post by:
3 employee's will be responsible for installing and maintaining IBM product set to include but not limited to Tivoli Access Manager 6.0, IBM Websphere Application Server, IBM MQ Server, and IBM DB2 application. Send resume' : jpa770@bellsouth.net
7
1386
by: Abhinay | last post by:
hi, sorry for asking this question in this forum, but i did't found any contact of concern person. My que is still unanswered so i wanted to post a message to my thread as per Posting Guidelines, but i dont know how to post a messge to my thead. can any budy help me ???? thank
4
1477
by: webandwe | last post by:
Hi I have a field box that will be used for GPS co-ordinates. But the " and ' mess my mysql query up. My code work like this. $a1=$_POST; query = "INSERT INTO information VALUES ('','$a1','$a2',...
0
10600
Oralloy
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...
0
10350
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
10351
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
9174
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...
0
6866
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();...
0
5534
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
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3834
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3002
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.