Concurrent Haskell (GHC) and Win32 Applications ?

Hi, I'm experimenting with GHC as a platform for writing a Win32 GUI application, and I've hit what I think is a brick wall. The problem I think is with the lightweight thread implementation - Win32 calls can (and will) block the OS thread that makes the call, which blocks the entire system. Given that I'm wanting to write a network server with a Win32 GUI, this is obviously a Bad Thing. So, does any know if I missing some vital piece of information? I am using the following reduced test case, which I don't think is clueless. import Win32 import Concurrent endless:: Char -> IO () endless c = do { putChar c; endless c } main = do { task1; task2; endless 'b' } where task1 = forkIO ( do { messageBox nullHANDLE "Hey" "Yeah" mB_OK; return () } ) task2 = forkIO ( endless 'a' ) It does intersperse the 'a' and 'b' output nicely, but stops while the message box is on the screen. I'm not keen on writing a seperate GUI management thread in C++ and linking - the point is to do all of this in Haskell and write an application indistinguishable from a C++ GUI app e.g. imagine Simon Peyton Jones' sample webserver with a realtime GUI monitor. Thanks in advance for any pointers!

Sat, Mar 09, 2002 at 11:44:22PM +1030, Antony Blakey ->
Hi, I'm experimenting with GHC as a platform for writing a Win32 GUI application, and I've hit what I think is a brick wall.
The problem I think is with the lightweight thread implementation - Win32 calls can (and will) block the OS thread that makes the call, which blocks the entire system. Given that I'm wanting to write a network server with a Win32 GUI, this is obviously a Bad Thing.
While I haven't used GHC with the Win32 GUI I've had a similar problem with the gtk+hs bindings. See the ``concurrent haskell'' thread in: http://haskell.org/pipermail/gtkhs/2002-February/thread.html Basically, make sure that a Haskell function is called once in a while (for example add it as a timer callback) and make this function call yeild. I'm not sure the Win32 API works the same way but it might be worth a try. /jonas -- %http://www.dtek.chalmers.se/~d99josve/ - d99josve@dtek.chalmers.se
participants (2)
-
Antony Blakey
-
Jonas Svensson