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

C#

 
AnswerRe: point to a class name with a string from xml Pin
Phillip M. Hoff30-Dec-06 16:22
Phillip M. Hoff30-Dec-06 16:22 
AnswerIm sorry but Pin
Ennis Ray Lynch, Jr.30-Dec-06 17:36
Ennis Ray Lynch, Jr.30-Dec-06 17:36 
QuestionHow to read data from COM port (want to get remote to work) Pin
daniilzol30-Dec-06 10:48
daniilzol30-Dec-06 10:48 
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 
I expect most IO drivers to use at least one additional thread to handle incoming data:
it needs buffering, decoding, signalling, etc even when there is no client thread actively
asking for anything from the IO. The obvious way to achieve this is for the IO
code to create a local thread;
when something needs signalling (thru a callback function, an event
handler, whatever), I expect that to be handled by the same additional thread.


If you want to verify this theory, you should try to obtain a thread ID (I do not
know by heart how to do this with managed code), do it once in the GUI thread,
and once in the DataReceived handler, and compare them !

Even simpler, you could just print the value of someControl.InvokeRequired from
within the DataReceived handler; if it is true, the above has been proven.


Also the MSDN documentation clearly states "The DataReceived event is raised on a secondary thread when data is received from the SerialPort object".
(see ms-help://MS.VSExpressCC.v80/MS.NETFramework.v20.en/cpref8/
html/E_System_IO_Ports_SerialPort_DataReceived.htm)

So in order to access GUI elements from receive handlers (DataReceived, and similarly
PinChanged and ErrorReceived) you should use Invoke and/or BeginInvoke to delegate the GUI work to the right thread.

BTW, that your program works right under some circumstances does not prove it is
correct; especially threading and synchronization problems can be hidden and
only show under some circumstances. Only correct code works all the time.

Smile | :)




-- modified at 22:34 Saturday 30th December, 2006

Luc Pattyn

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 
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 

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.