开发者

Why .NET does not allow cross-thread operations? [duplicate]

This question already has answers here: Closed 12 years ago.

Possible Duplicate:

.NET Controls: Why aren’t all calls thread-safe?

This question i开发者_JAVA技巧s not about what is a cross-thread operation, and how to avoid it, but why internal mechanics of .NET framework does not allow a cross-thread operation.

I can`t understand why a SerialPort DataReceived event cannot update a simple text box on my form and why using delegates this is possible?


.NET allows cross-thread operations. But you should handle it safely. Use Invoke / BeginInvoke methods for cross-thread operations. Invoke means "Hey, text box! Please update yourself when you will have time." Here is an example of usage on MSDN

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜