Click here to Skip to main content
15,919,931 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to read data from COM port (want to get remote to work) Pin
Dave Kreskowiak30-Dec-06 11:29
mveDave Kreskowiak30-Dec-06 11:29 
GeneralRe: How to read data from COM port (want to get remote to work) [modified] Pin
daniilzol30-Dec-06 11:46
daniilzol30-Dec-06 11:46 
GeneralRe: How to read data from COM port (want to get remote to work) Pin
gnadeem30-Dec-06 13:29
gnadeem30-Dec-06 13:29 
GeneralRe: How to read data from COM port (want to get remote to work) Pin
daniilzol30-Dec-06 14:54
daniilzol30-Dec-06 14:54 
GeneralRe: How to read data from COM port (want to get remote to work) [modified] Pin
Luc Pattyn30-Dec-06 16:11
sitebuilderLuc Pattyn30-Dec-06 16:11 
GeneralRe: How to read data from COM port (want to get remote to work) Pin
daniilzol31-Dec-06 8:13
daniilzol31-Dec-06 8:13 
QuestionSocket IO interaction with UI Message pump Question? Pin
Member 288953130-Dec-06 10:43
Member 288953130-Dec-06 10:43 
AnswerRe: Socket IO interaction with UI Message pump Question? Pin
Phillip M. Hoff30-Dec-06 17:00
Phillip M. Hoff30-Dec-06 17:00 
I don't think the problem is any inherent link between Application.DoEvents() and socket I/O. Instead, I believe the problem is the WaitHandle.WaitAll() which blocks the UI thread. If your threads are performing socket I/O, then calling into your UI component which calls Invoke() to get to the UI thread, the WaitHandle.WaitAll() indirectly blocks your threads which will slow your socket I/O. (Remember that Invoke() will block the calling thread until the delegate method completes on the UI thread.) The reason why the Application.DoEvents() makes the application appear to work is that it allows another Invoke() to start executing (which might then call Application.DoEvents() again, and so on, and so forth). Usually this recursive process will end on its own and the Invoke() chain will complete and dissolve itself with no issues. However, the more nested calls there are, the more likely it is to result in a deadlock or other undesirable behavior. Hence, the use of Application.DoEvents() is discouraged.

The way to model your application is to have the threads fire events when certain things happen. The UI components can then subscribe to these events and update their display accordingly. The key thing is that the UI components never actively wait (i.e. block) on the UI thread for the events to occur. The threads themselves do the notifying. This keeps the application's message pump running smoothly.

As a side note, if your UI components properties are only set from the UI thread (i.e. from within an Invoke(), which is good form anyway), then there is no need for them to have locks because access is, by definition, serialized. Locks in this case would just slow things down unnecessarily.

-Phil
Questionproblem for set RememberMe CheckBox in ASP.net Login Control. Pin
hdv21230-Dec-06 10:04
hdv21230-Dec-06 10:04 
AnswerRe: problem for set RememberMe CheckBox in ASP.net Login Control. Pin
Brad Bruce30-Dec-06 10:59
Brad Bruce30-Dec-06 10:59 
QuestionGUI for remote reboots using Shutdown command Pin
namedalias530-Dec-06 8:09
namedalias530-Dec-06 8:09 
AnswerRe: GUI for remote reboots using Shutdown command Pin
Luc Pattyn30-Dec-06 8:54
sitebuilderLuc Pattyn30-Dec-06 8:54 
GeneralRe: GUI for remote reboots using Shutdown command Pin
namedalias530-Dec-06 9:02
namedalias530-Dec-06 9:02 
GeneralRe: GUI for remote reboots using Shutdown command Pin
Luc Pattyn30-Dec-06 9:25
sitebuilderLuc Pattyn30-Dec-06 9:25 
GeneralRe: GUI for remote reboots using Shutdown command Pin
namedalias530-Dec-06 9:29
namedalias530-Dec-06 9:29 
QuestionFolder Protection.. Pin
kkadir30-Dec-06 8:01
kkadir30-Dec-06 8:01 
AnswerRe: Folder Protection.. Pin
Luc Pattyn30-Dec-06 8:56
sitebuilderLuc Pattyn30-Dec-06 8:56 
AnswerRe: Folder Protection.. Pin
Ami Bar30-Dec-06 10:28
Ami Bar30-Dec-06 10:28 
GeneralRe: Folder Protection.. Pin
kkadir30-Dec-06 11:39
kkadir30-Dec-06 11:39 
GeneralRe: Folder Protection.. Pin
Dave Kreskowiak30-Dec-06 17:08
mveDave Kreskowiak30-Dec-06 17:08 
AnswerKind of Pin
Ennis Ray Lynch, Jr.30-Dec-06 17:38
Ennis Ray Lynch, Jr.30-Dec-06 17:38 
QuestionOpen "Windows Image Fax Viewer" Pin
greekius30-Dec-06 7:33
greekius30-Dec-06 7:33 
AnswerRe: Open "Windows Image Fax Viewer" Pin
Luc Pattyn30-Dec-06 9:21
sitebuilderLuc Pattyn30-Dec-06 9:21 
AnswerRe: Open "Windows Image Fax Viewer" Pin
Luc Pattyn30-Dec-06 9:33
sitebuilderLuc Pattyn30-Dec-06 9:33 
AnswerRe: Open "Windows Image Fax Viewer" Pin
Luc Pattyn30-Dec-06 9:35
sitebuilderLuc Pattyn30-Dec-06 9:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.