ActiveX freezes IE

ぃ、小莉子 提交于 2019-12-13 17:27:06

问题


I created an activeX control to perform some actions, which take about 1 minute. During this action IE freezes completely. Is there a way to call the activeX control so that IE does not freeze?

Thank you


回答1:


This is a threading issue dealing with IE, so I don't think there is any way to do this.




回答2:


You would have the same problem in any ActiveX host, not just IE. If you don't want to block the UI thread, then you need to change your ActiveX control to do its work on a secondary thread.




回答3:


I had a simulair problem with my activeX that freezed IE. I managed to do a workaround, by letting my activeX control create new threads on client. Even tho the thread is doing its work, the activeX returns that its done and will unblock UI.

The tricky part is to know when the thread is done. You can find out by have a boolean property in your activeX, that you set to true when the thread is completed. From javascript you can keep invoke that property until its set to true.

Javascript:

var myActiveXObject = new ActiveXObject("myActiveX");

function startWork()
{
    myActiveXObject.startWork();

    setTimeout(checkIsDone(), 1000);
}

function checkIsDone()
{
    if(myActiveXObject.checkIsDone())
        workComplete();
    else
        setTimeout(checkIsDone(), 1000);
}

ActiveX:

private bool blnIsDone;

[ComVisible(true)]
public void startWork()
{
   blnIsDone = false;

   Thread myThread = new Thread(delegate()
   {
       ThreadedWork();
   });

   myThread.Start();
}

private ThreadedWork()
{
    //Do work

    blnIsDone = true;
}

[ComVisible(true)]
public bool checkIsDone()
{
   return blnIsDone;
}


来源:https://stackoverflow.com/questions/853902/activex-freezes-ie

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!