[MonoTouch] Invo

2011-08-11 Thread Matteo Polito
Hi,

why if I execute this code my app freeze? To use again my app I need to
close and reopen it. I've used this code(threadpool and ManualResetEvent)
because I need to execute a method on thread but I need to wait its
completion.

var resetEvent = new ManualResetEvent(false);
ThreadPool.QueueUserWorkItem(
arg =
{
this.InvokeOnMainThread(delegate
{
UIAlertView _AlertView = new UIAlertView(Test, Test, null, OK, null);
_AlertView.Show();
});
resetEvent.Set();
});
resetEvent.WaitOne();


Do you know why?

Someone can help me?
___
MonoTouch mailing list
MonoTouch@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/monotouch


Re: [MonoTouch] Invo

2011-08-11 Thread Robert Jordan
On 11.08.2011 21:13, Matteo Polito wrote:
 Hi,

 why if I execute this code my app freeze? To use again my app I need to
 close and reopen it. I've used this code(threadpool and ManualResetEvent)
 because I need to execute a method on thread but I need to wait its
 completion.

 var resetEvent = new ManualResetEvent(false);
 ThreadPool.QueueUserWorkItem(
  arg =
  {
 this.InvokeOnMainThread(delegate
  {
 UIAlertView _AlertView = new UIAlertView(Test, Test, null, OK, null);
 _AlertView.Show();
 });
  resetEvent.Set();
  });
 resetEvent.WaitOne();


 Do you know why?


The main thread is blocked by resetEvent.WaitOne(), and
InvokeOnMainThread is probably crashing because of this.

Robert

___
MonoTouch mailing list
MonoTouch@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/monotouch