[Using VS2010 Beta and .Net Framework 3.5]

I'm coding a component (in C#) to listen on a socket and raise events when data arrives. The component is placed on a form (in VB), which subscribes to its events, and shows a message box when it receives the events.

When the component raises an event synchronously, the message box locks the form and halts the component, and appears on top of it, as normal. Two seconds AFTER clicking the OK button, when the event is raised asynchronously, the message box appears as its own form - it shows up in the taskbar, and doesn't stay above the form which called it.

I want the first event raised (syncEvent) to not block the component code (the component continues operating even if the user doesn't hit OK) but still lock the form, and I want the second event (asyncEvent) to not block the component code and also lock the form. (Also - I want to change the component code - I shouldn't have to change the form at all.)

Any help?
Thanks!

[Component code]
using System;
using System.Threading;
using System.ComponentModel;

namespace mySpace
{
public delegate void SyncEventHandler(object sender, SyncEventArgs e);
public delegate void AsyncEventHandler(object sender, AsyncEventArgs e);

public class myClass
{
readonly object syncEventLock = new object();
readonly object asyncEventLock = new object();

SyncEventHandler syncEvent;
AsyncEventHandler asyncEvent;

private delegate void WorkerDelegate(string strParam, int intParam);

public void DoWork(string strParam, int intParam)
{
// This blocks until the message box is closed
OnSyncEvent(new SyncEventArgs());
AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(null);
WorkerDelegate delWorker = new WorkerDelegate(ClientWorker);
IAsyncResult result = delWorker.BeginInvoke(strParam, intParam, null, null);
}

private void ClientWorker(string strParam, int intParam)
{
Thread.Sleep(2000);
// This blocks until the message box is closed
OnAsyncEvent(new AsyncEventArgs());
}

public event SyncEventHandler SyncEvent
{
add { lock (syncEventLock) syncEvent += value; }
remove { lock (syncEventLock) syncEvent -= value; }
}
public event AsyncEventHandler AsyncEvent
{
add { lock (asyncEventLock) asyncEvent += value; }
remove { lock (asyncEventLock) asyncEvent -= value; }
}

protected void OnSyncEvent(SyncEventArgs e)
{
SyncEventHandler handler;
lock (syncEventLock) handler = syncEvent;
if (handler != null) handler(this, e);
}
protected void OnAsyncEvent(AsyncEventArgs e)
{
AsyncEventHandler handler;
lock (asyncEventLock) handler = asyncEvent;
if (handler != null) handler(this, e);
}
}
}


[Form Code]
Imports mySpace

Public Class Form1

Public WithEvents component As New pbxapi.myClass()

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
component.DoWork("String", 1)
End Sub

Private Sub component_SyncEvent(ByVal sender As Object, ByVal e As pbxapi.SyncEventArgs) Handles component.SyncEvent
'This locks the form and blocks the component until OK is clicked
MessageBox.Show("Synchronous event", "Raised:", MessageBoxButtons.OK)
End Sub

Private Sub component_AsyncEvent(ByVal sender As Object, ByVal e As pbxapi.AsyncEventArgs) Handles component.AsyncEvent
'This doesn't lock the form
MessageBox.Show("Asynchronous event", "Raised:", MessageBoxButtons.OK)
End Sub
End Class