看板 C_Sharp 關於我們 聯絡資訊
: 我是打算寫一個C++ 視窗網路程式。 : 用另一個thread專門聽別人送封包過來。 : 如果送過來了。 : 就產生一個form顯示那個人傳訊息的內容。 : 就像是msn之類的,別人丟訊息過來,就會跳出一個視窗。 : 所以我才來問怎樣在thread中產生視窗。 不好意思 昨日不在 回覆有點慢... C# 不會自動為每個 form 產生各自的 UI thread 必須明確使用方法來為每個form產生一個 UI thread ( UI thread 就是負責該視窗 message handling 的 thread ) 所以如果你用某個 thread 產生一個 form 而沒有另外指定要有其獨立的 UI thread 就糟糕啦~ 沒人要負責啦~ C#裡面用 Application.Run() 來完成這件事 當你在某個thread裡面寫下這一行 你這個thread就必須作為這個form的UI thread了 一個 thread 只能當一個 form 的 UI thread... 所以你想要的功能就是產生一個 thread 然後在thread裡寫下 Application.Run(new YourForm()) 就好了 其他接收訊息還有UI的功能就寫在 YourForm 裡面 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.115.217.14
miewQ:謝謝你^^ 03/06 01:48