A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

BackGroundWorker.ProgressChanged "Cross-thread operation not valid" at 2nd/3th/... progress



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old February 13th 06, 04:00 PM posted to microsoft.public.dotnet.framework,microsoft.public.dotnet.general,microsoft.public.dotnet.languages.vb,microsoft.public.outlook.program_vba
Josh Einstein
external usenet poster
 
Posts: 57
Default BackGroundWorker.ProgressChanged "Cross-thread operation not valid" at 2nd/3th/... progress

Oh I should also mention that your error here doesn't have anything to do
with the cross-thread Outlook access but I would avoid that anyway.

Your error message here is the same thing Dmytro said about cross-thread UI
calls. Something you are doing in DoWork (which is in a background thread)
is modifying the data grid. You can't do any UI access in DoWork. Only in
ProgressChanged or RunWorkerCompleted.

But again, I would avoid accessing the Outlook API from a background thread.
It is not thread-safe and behaves unpredictably whether or not you employ
locking.

--
Josh Einstein
Einstein Technologies
Microsoft Tablet PC MVP
Tablet Enhancements for Outlook 2.0 - Try it free for 14 days
www.tabletoutlook.com


"Pieter" wrote in message
...
Hi,

I've tryed it, but it didn't work either :-/
And isn't the BackGroundWorker designed so we shouldn't worry anymore
about those Invoke and Delegates-stuff?

This is my new code with Invoke, which doesn't work either... :-/

Private Sub bgwInfoOutlook_ProgressChanged(ByVal sender As Object,
ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles
bgwInfoOutlook.ProgressChanged
Try
SetDataSource()
Catch ex As Exception
ErrorMessage(ex)
End Try
End Sub

Delegate Sub SetDgvCallback()

Private Sub SetDataSource()
If Me.dgvAdd.InvokeRequired Then
Dim d As New SetDgvCallback(AddressOf SetDataSource)
Me.Invoke(d, Nothing)
Else
Me.dgvAdd.DataSource = Nothing
Me.dgvAdd.DataSource = docCtrl.InfoList
End If
End Sub

And the werit thing is: the Me.dgvAdd.InvokeRequired returns False...

"Dmytro Lapshyn [MVP]" wrote in message
...
Hi Pieter,

As far as I know, .NET 2.0 strictly prohibits any access to the user
interface from background worker threads. This wasn't allowed in .NET 1.1
either, but in that version one sometimes could get away with violating
the rule. Now you'll get the "Cross-thread operation not valid" almost
for sure.

Therefore, to do any updates to the UI properly, you should use the
Control.Invoke method to run the UI update code on the UI thread.





  #2  
Old February 13th 06, 04:10 PM posted to microsoft.public.dotnet.framework,microsoft.public.dotnet.general,microsoft.public.dotnet.languages.vb,microsoft.public.outlook.program_vba
Pieter
external usenet poster
 
Posts: 27
Default BackGroundWorker.ProgressChanged "Cross-thread operation not valid" at 2nd/3th/... progress

"Josh Einstein" wrote in message
...

Your error message here is the same thing Dmytro said about cross-thread
UI calls. Something you are doing in DoWork (which is in a background
thread) is modifying the data grid.


Well actually it isn't :-/
And I don't have the exception while the Dowork is performing its actions:
it happens when the ProgressChanged-event fires...



  #3  
Old February 13th 06, 05:29 PM posted to microsoft.public.dotnet.framework,microsoft.public.dotnet.general,microsoft.public.dotnet.languages.vb,microsoft.public.outlook.program_vba
Josh Einstein
external usenet poster
 
Posts: 57
Default BackGroundWorker.ProgressChanged "Cross-thread operation not valid" at 2nd/3th/... progress

You'll have to recheck your code. Set a breakpoint and look at the threads
window. You are definitely accessing the UI from the background thread
somewhere. ProgressChanged and RunWorkerCompleted are raised on the UI
thread. (Which is why InvokeRequired returns false.)

--
Josh Einstein
Einstein Technologies
Microsoft Tablet PC MVP
Tablet Enhancements for Outlook 2.0 - Try it free for 14 days
www.tabletoutlook.com


"Pieter" wrote in message
...
"Josh Einstein" wrote in message
...

Your error message here is the same thing Dmytro said about cross-thread
UI calls. Something you are doing in DoWork (which is in a background
thread) is modifying the data grid.


Well actually it isn't :-/
And I don't have the exception while the Dowork is performing its actions:
it happens when the ProgressChanged-event fires...





 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
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


All times are GMT +1. The time now is 06:25 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.