![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
Hi,
I'm having some weird problem using the BackGroundWorker in an Outlook (2003) Add-In, with VB.NET 2005: I'm using the BackGroundWorker to get the info of some mailitems, and after each item I want to raise the ProgressChanged-event to update the DataGridView. It works fine when only one Progresschanged is fired, but at the second, third, fopurth etc it raises everytile a 'Cross-thread operation not valid"-exception on lmy DataGridView (dgvAdd). Any idea what causes this problem? What am I doing wrong? What is the problem here? Any help our hints would be really appreciated! Thanks a lot in advance, Pieter This is my code: Me.bgwInfoOutlook.RunWorkerAsync(Me.m_colItems) Private Sub bgwInfoOutlook_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles bgwInfoOutlook.DoWork Dim col As Collection = e.Argument AddHandler docCtrl.InfoListChanged, AddressOf InfoListChanged Dim str As String = docCtrl.GetOutlookInfo(col, Me.m_objOutlookFolder) e.Result = docCtrl.AddedDocMails End Sub Private Sub InfoListChanged(ByVal sender As Object, ByVal e As EventArgs) Me.bgwInfoOutlook.ReportProgress(0) End Sub Private Sub bgwInfoOutlook_ProgressChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles bgwInfoOutlook.ProgressChanged 'bind the list to the datagridview Try Me.dgvAdd.DataSource = Nothing Me.dgvAdd.DataSource = docCtrl.InfoList Catch ex As Exception ErrorMessage(ex) End Try End Sub This is the exception: {"Cross-thread operation not valid: Control 'dgvAdd' accessed from a thread other than the thread it was created on."} System.InvalidOperationException: {"Cross-thread operation not valid: Control 'dgvAdd' accessed from a thread other than the thread it was created on."} Data: {System.Collections.ListDictionaryInternal} HelpLink: Nothing InnerException: Nothing Message: "Cross-thread operation not valid: Control 'dgvAdd' accessed from a thread other than the thread it was created on." Source: "System.Windows.Forms" StackTrace: " at System.Windows.Forms.Control.get_Handle() at System.Windows.Forms.Control.get_InternalHandle() at System.Windows.Forms.Control.get_CreateParams() at System.Windows.Forms.ScrollBar.get_CreateParams() at System.Windows.Forms.VScrollBar.get_CreateParams() at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32 width, Int32 height) at System.Windows.Forms.Control.SetBoundsCore(Int32 x, Int32 y, Int32 width, Int32 height, BoundsSpecified specified) at System.Windows.Forms.Control.SetBounds(Int32 x, Int32 y, Int32 width, Int32 height, BoundsSpecified specified) at System.Windows.Forms.Control.set_Bounds(Rectangle value) at System.Windows.Forms.DataGridView.LayoutScrollBars () at System.Windows.Forms.DataGridView.ComputeLayout() at System.Windows.Forms.DataGridView.PerformLayoutPri vate(Boolean useRowShortcut, Boolean computeVisibleRows, Boolean invalidInAdjustFillingColumns, Boolean repositionEditingControl) at System.Windows.Forms.DataGridView.OnColumnWidthCha nged(DataGridViewColumnEventArgs e) at System.Windows.Forms.DataGridView.OnBandThicknessC hanged(DataGridViewBand dataGridViewBand) at System.Windows.Forms.DataGridViewBand.set_Thicknes sInternal(Int32 value) at System.Windows.Forms.DataGridView.AdjustFillingCol umns() at System.Windows.Forms.DataGridView.ComputeLayout() at System.Windows.Forms.DataGridView.PerformLayoutPri vate(Boolean useRowShortcut, Boolean computeVisibleRows, Boolean invalidInAdjustFillingColumns, Boolean repositionEditingControl) at System.Windows.Forms.DataGridView.ResetUIState(Boo lean useRowShortcut, Boolean computeVisibleRows) at System.Windows.Forms.DataGridViewRowCollection.OnC ollectionChanged_PreNotification(CollectionChangeA ction cca, Int32 rowIndex, Int32 rowCount, DataGridViewRow& dataGridViewRow, Boolean changeIsInsertion) at System.Windows.Forms.DataGridViewRowCollection.OnC ollectionChanged(CollectionChangeEventArgs e, Int32 rowIndex, Int32 rowCount, Boolean changeIsDeletion, Boolean changeIsInsertion, Boolean recreateNewRow, Point newCurrentCell) at System.Windows.Forms.DataGridViewRowCollection.Ins ertInternal(Int32 rowIndex, DataGridViewRow dataGridViewRow, Boolean force) at System.Windows.Forms.DataGridView.DataGridViewData Connection.ProcessListChanged(ListChangedEventArgs e) at System.Windows.Forms.DataGridView.DataGridViewData Connection.currencyManager_ListChanged(Object sender, ListChangedEventArgs e) at System.Windows.Forms.CurrencyManager.OnListChanged (ListChangedEventArgs e) at System.Windows.Forms.CurrencyManager.List_ListChan ged(Object sender, ListChangedEventArgs e) at System.ComponentModel.BindingList`1.OnListChanged( ListChangedEventArgs e) at System.ComponentModel.BindingList`1.FireListChange d(ListChangedType type, Int32 index) at System.ComponentModel.BindingList`1.InsertItem(Int 32 index, T item) at System.Collections.ObjectModel.Collection`1.Add(T item) at BaseFramework.clsBaseList`1.Add(T item) in D:\NET Projecten\Code Source Sodimex - Ghost\BaseFramework\clsBaseList.vb:line 461 at DocControl.clsDocControl.GetOutlookInfo(Collection colItems, Object oFolder, Boolean blnAttachments) in D:\NET Projecten\Code Source Sodimex - Ghost\DocControl\Business Layer\clsDocControl.vb:line 597" TargetSite: {System.Reflection.RuntimeMethodInfo} |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Outlook 2002 "The operation Failed" when clicking Send/Receive | Douglas Hay | Outlook - General Queries | 2 | March 6th 06 04:34 PM |
How Do I Set Free/Busy to show "no information" cross hatches? | zrated2 | Outlook - Calandaring | 1 | February 10th 06 09:02 PM |
Outlook.ApplicationClass.CreateItem: "The operation failed." | Bruce Wood | Outlook and VBA | 2 | February 1st 06 01:12 AM |
can't send/receive in OL2003. "operation failed. object missing" | sk | Outlook - Installation | 0 | January 26th 06 01:40 PM |
Why is "FAX" a valid e-mail type in address book? | Opus | Outlook - Using Contacts | 3 | January 13th 06 08:24 PM |