Oh, wait:

member x.SquareIsReady = new Event()

every time you read that property, it creates a new, distinct event. I think you want

let e = new Event()

member x.SquareIsReady = e

By on 6/29/2010 5:34 PM ()

Avoid Async.RunSynchronously in favor of Async.StartImmediate in many cases.

That said, I don't think that general advice applies here. It seems (from what you're asking) like you really do want to block the UI while waiting for an event to be fired on the background controller thread (yes?). But RunSynchronously is called on the UI thread, right (that's what the code suggests to me, though your phrasing of the question suggests otherwise)? Please give a little clarification, before I try to offer advice. :)

In any case, stack traces of all threads at the point of deadlock is a useful way to troubleshoot.

By on 6/29/2010 5:19 PM ()

Avoid Async.RunSynchronously in favor of Async.StartImmediate in many cases.

That said, I don't think that general advice applies here.  It seems (from what you're asking) like you really do want to block the UI while waiting for an event to be fired on the background controller thread (yes?).  But RunSynchronously is called on the UI thread, right (that's what the code suggests to me, though your phrasing of the question suggests otherwise)?  Please give a little clarification, before I try to offer advice.  :)

Sorry, the detail I didn't post is that the UI is created on a separate STAThread when you create the FSPlayers. So RunSyncrhonously is called on the controller thread, i.e. I'm blocking the controller thread while waiting for the UI, just like Console.ReadLine().

Your next post is spot-on about the problem: I hadn't considered that a new event was being created every time. Your fix worked, too, and I now know how to declare events correctly in F#. Thanks!

-Max

By on 6/30/2010 7:40 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper