2010年5月10日 星期一

終於找到timeRadio有時候會停住的關係了

因為之前用的timer是用Form.Timer,這是使用UI Form的thread,簡單來說,根本就是同條thread上,難怪timer上作的事件卡住,視窗就跟著一起停住了!

C# 的timer有分作3類:
  • System.Windows.Forms.Timer

  • System.Threading.Timer

  • System.Timers.Timer

  •  

    然而除Forms.Timer是使用UI thread,其餘兩個都是不同thread去做事的

    另外,這些timer並不是叫他stop就真的stop,具體原因請參考底下連結

    參考 http://blog.csdn.net/BusyDonkey/archive/2010/02/25/5327665.aspx

    相同的,因為在不同thread,自然而然要處理跨thread處理UI form訊息的問題了

    C# 好像沒有好用的sendMessage可以用來跨thread送訊息 (沒想到我竟然開始懷念MFC)

    只能乖乖的用delegate,慢慢處理了

    2 則留言:

    1. A bit srupriesd it seems to simple and yet useful.

      [WORDPRESS HASHCASH] The poster sent us '0 which is not a hashcash value.

      回覆刪除
    2. Attractive part of content. I simply stumbled upon your site and in accession capital to claim that I get actually enjoyed account your weblog posts.
      Any way I'll be subscribing for your augment and even I achievement you access persistently fast.

      [WORDPRESS HASHCASH] The poster sent us '0 which is not a hashcash value.

      回覆刪除