when i click on connection button this backgroundWorkerStartupProcessLoader start:
private void backgroundWorkerStartupProcessLoader_DoWork(object sender, DoWorkEventArgs e)
{
//constructor of web browser
OAuthPopup oauthPopup = new OAuthPopup(_ippRealmOAuthProfile);
}
//OAuthPopup .cs
public OAuthPopup(IppRealmOAuthProfile ippRealmOAuthProfile)
{
try
{
initializeComponent() ;
_ippRealmOAuthProfile = ippRealmOAuthProfile;
readConsumerKeysFromConfiguration();
startOAuthHandshake();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
#region " Redirect to Service Provider - IPP "
private void redirectToIppForUserAuthorization(OnlineQBO.DevDefined.OAuth.Framework.IToken requestToken)
{
try
{
// put existing web browser code in here
var oauthUserAuthorizeUrl = "https://appcenter.intuit.com/Connect/Begin";
this.oauthBrowser.Navigate(oauthUserAuthorizeUrl + "?oauth_token=" + requestToken.Token + "&oauth_callback=" + OnlineQBO.DevDefined.OAuth.Framework.UriUtility.UrlEncode(_dummyProtocol + _dummyHost));
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
#endregion
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
I got the error when the intializeComponent() or oauthBrowser.Navigate method called.
actual problem is whenever backgroungworker start , he is not going to initiate UI control(web browser)
Please help me ..
Loading
VulpesPosted May 2, 2014, 9:23 AM
A web browser control is a COM object which needs to be created on an STA thread with a message pump i.e. the UI thread of a Windows Forms application.
So, if you need to use a Backgroundworker for some reason, then create the web browser control on the main UI thread first and then access it via the ProgressChanged or RunWorkerCompleted event handlers which are called on the UI thread.
If for some reason you have to access it in the DoWork handler, then marshal the accessing code back to the UI thread using the Invoke or BeginInvoke methods.
Mrudul GanpulePosted May 2, 2014, 9:39 AM