开发者

Calling COM Method From UI Thread Problem

I wonder if you could help me solve my COM problem. I have a program that calls a COM method when the button is clicked. The code looks something like this:

private void Send_Click(object sender, EventArgs e)
{
    p.Send(allChanges);
}

This code works fine. Bu开发者_Python百科t I have another program that calls the same COM method. the code looks like this:

private void Publish(List<Tuple<string, DataPair>> allChanges)
{
    var d = new SendCallback(Send);
    d.BeginInvoke(allChanges, null, null);
}

As you can see here I invoke the COM method using a delegate. If I don't use delegate, the program will crash due to COM exception.

The underlying Send function is the same.

Could anyone please advise? Thanks very much.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜