Itamarqaz

Hi all ,

I have an app. which send request to COM objct and receive events from the object.

The request and the events back are not sync.

My problem is that everything is in the same thread , and while I am sending requests I can see that I am getting the event but while it start processing the event I am getting another event

I cant change the COM object,

This is the delegate for the event

PaApiFuncs.PAEvent += new PAAPICOMLib._IPAApiEvents_PAEventEventHandler(PaEventFuncAsync);

This is the function which handle the event which I cant process

private void PaEventFuncAsync(int eventCode, int OperationCode, string Data)

{

listView2.Items.Add(OperationCode.ToString());

listView2.Items[listView2.Items.Count - 1].SubItems.Add(((PAOpcode_)OperationCode).ToString());

listView2.Items[listView2.Items.Count - 1].SubItems.Add(Data);

}

And this is the function which sends the request

while ((FileLine = srFile.ReadLine()) != null)

{

listView1.Items.Add(OperationCode.ToString());

listView1.Items[listView1.Items.Count - 1].SubItems.Add(((PAOpcode_)OperationCode).ToString());

listView1.Items[listView1.Items.Count - 1].SubItems.Add(Data);

listView1.Refresh();

listView1.EnsureVisible(listView1.Items.Count-1);

try

{

if (cbSendEvents.Checked == true)

Rc = PaApiFuncs.PARequest(OperationCode, Data);

}

catch (Exception err)

{

MessageBox.Show(err.Message);

}

}

Thanks very much