
Untitled
By: a guest on
May 9th, 2012 | syntax:
None | size: 2.11 KB | hits: 15 | expires: Never
Creating Dialog with WebBrowser from BackgroundWorker
protected bool ValidatePage( bool pagePasses, string msg ) {
if ( pagePasses == false ) {
AbortIgnoreSuspend ais = new AbortIgnoreSuspend( responsehtml, msg );
ais.ShowDialog();
switch ( ais.DialogResult ) {
case DialogResult.Abort: // Aborts entire thread
Abort = true;
worker.CancelAsync();
return false;
case DialogResult.Cancel: // Aborts this case
Abort = true;
return false;
case DialogResult.Ignore: // Ignore and continue
return true;
case DialogResult.Retry: // Debug
Debug.Assert( false, "Suspending Thread" );
return true; // Will return you to calling thread and allow you to continue
default:
return true;
}
}
return true;
}
protected bool ValidatePage( bool pagePasses, string msg ) {
if ( pagePasses == false ) {
bool setAbort = false;
bool assertError = false;
bool cancelWorker = false;
bool returnContinue = true;
Thread th = new Thread( () => {
AbortIgnoreSuspend ais = new AbortIgnoreSuspend( responsehtml, msg );
ais.ShowDialog();
switch ( ais.DialogResult ) {
case DialogResult.Abort: // Aborts entire thread
setAbort = true;
cancelWorker = true;
returnContinue = false;
break;
case DialogResult.Cancel: // Aborts this case
setAbort = true;
returnContinue = false;
break;
case DialogResult.Ignore: // Ignore and continue
returnContinue = true;
break;
case DialogResult.Retry: // Debug
assertError = true;
returnContinue = true; // Will return you to calling thread and allow you to continue
break;
default:
returnContinue = true;
break;
}
} );
th.SetApartmentState( ApartmentState.STA );
th.Start();
th.Join();
Abort = setAbort;
Debug.Assert( !assertError, "Suspending thread for debugging" );
if ( cancelWorker ) { worker.CancelAsync(); }
return returnContinue;
}
return true;
}