title: Hook message loop in Windows Forms application?
body: <p>I need to hook the message loop in a Windows Forms application to do some tick-count related work.</p>
  
  <p>I'm developing a tcp server using async methods (async/await) and I'm avoiding dealing with race conditions in a multi-threaded process - this is basically the reason I'm using async/await instead of other models. Because of this restriction, I can't create a background thread to do the tick-counting because with this I will end up in a multi-threaded code.</p>
  
  <p>An option I thought was to somehow hook up the message loop in the Windows Forms, so I could easily do my tick-count related stuff using the same thread of my Windows Forms object, although I didn't find any suitable method or event in the Windows.Forms.Application class.</p>
  
  <p>Anyone knows a way to do what I need?</p>
  
  <p>Thanks.</p>