When I use the following method I get a RaceOnRCWCleanup condition on
"explorerManager.DisconnectAndClose();"
protected void CloseInternetExplorer(ExplorerManager explorerManager)
{
try
{
int processID = explorerManager.ProcessId;
explorerManager.DisconnectAndClose();
Process.GetProcessById(processID).WaitForExit(1000);
}
catch(Exception e)
{
Console.WriteLine("ERROR CLOSING " + e);
}
}
If I do further checks I see the following error
An unhandled exception of type
'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll
Additional information: @##SWException##@<Error><FileName>.
\GlobalObjectTableImpl.cpp</FileName><LineNumber>247</
LineNumber><FileTimeStamp>Sat May 5 23:00:34 2007</
FileTimeStamp><Time>16/05/2007 10:57:39</Time><User>User</
User><Computer>WINXP1</Computer><ThreadId>1760</
ThreadId><HRESULT>ffffffff</HRESULT><Description>Object is not found</
Description><GUID>{00000000-0000-0000-0000-000000000000}</
GUID><HelpContext>0</HelpContext><HelpFile></HelpFile><Source></
Source></Error><Error><HRESULT>ffffffff</HRESULT><Description>Unknown
error 0xFFFFFFFF</
Description><GUID>{00000000-0000-0000-0000-000000000000}</
GUID><HelpContext>0</HelpContext><HelpFile></HelpFile><Source></
Source></Error>
Any ideas?
Ash
The code doesn't reproduce the problem.
Could you send me a code example which reproduces the problem?
Regards,
Alex Furman
You should be able to reporduce the error if you do something like
this. It's even more replicatable if you use many threads to open and
close IE.
for (int i = 0; i < 100; i++)
{
CloseInternetExplorer(explorerManager);
explorerManager.Connect(-1);
}
Ash
I have just run the code and it doesn't reproduce the problem:
public static void Main() {
for (int i = 0; i < 10; i++)
{
SWExplorerAutomation.Client.ExplorerManager explorerManager =
new SWExplorerAutomation.Client.ExplorerManager();
explorerManager.Connect();
int processId = explorerManager.ProcessId;
explorerManager.DisconnectAndClose();
Process.GetProcessById(processId).WaitForExit();
}
}
In any case I don't recommend creating IE instances concurrently. It
is better to pre-create pool of IE instances and use them.
Best Regards,
Alex Furman