vikasde
vikasde

Reputation: 5751

ActiveX freezes IE

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

Upvotes: 1

Views: 1676

Answers (3)

Jimmy Mattsson
Jimmy Mattsson

Reputation: 2113

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;
}

Upvotes: 4

Paul Sonier
Paul Sonier

Reputation: 39480

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

Upvotes: 1

Joe White
Joe White

Reputation: 97696

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.

Upvotes: 6

Related Questions