开发者

Calling COM Method From UI Thread Problem

开发者 https://www.devze.com 2023-04-07 23:54 出处:网络
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:

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

精彩评论

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

关注公众号