When using a method like ClickNoWait, a new thread is being created and code is executed on it.
In case of an exception on the other thread, the entire application crashes since it is not handled in the new thread.
A proposed fix (that i am currently using for this):
public static void AsyncActionOnBrowser(ThreadStart action, bool catchExceptions) { var thread = new Thread(() => { try { action(); } catch (Exception e) { Logger.LogDebug("An exception has occured during AsyncActionOnBrowser(): {0}", e);
if (!catchExceptions) { throw; } } }); thread.SetApartmentState(ApartmentState.STA); thread.Start(); thread.Join(500); }
Log in to post a comment.
A proposed fix (that i am currently using for this):
public static void AsyncActionOnBrowser(ThreadStart action, bool catchExceptions)
{
var thread = new Thread(() =>
{
try
{
action();
}
catch (Exception e)
{
Logger.LogDebug("An exception has occured during AsyncActionOnBrowser(): {0}", e);