Click here to Skip to main content
15,897,704 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Problem in IF statement Pin
Luc Pattyn2-Oct-09 2:20
sitebuilderLuc Pattyn2-Oct-09 2:20 
QuestionDataGridView Checkbox - Check Event Pin
jeshra2791-Oct-09 19:44
jeshra2791-Oct-09 19:44 
AnswerRe: DataGridView Checkbox - Check Event Pin
Tom Deketelaere1-Oct-09 22:48
professionalTom Deketelaere1-Oct-09 22:48 
AnswerRe: DataGridView Checkbox - Check Event Pin
decuria7-Dec-10 8:32
decuria7-Dec-10 8:32 
QuestionFTP in vb.net Pin
JollyMansArt1-Oct-09 17:21
JollyMansArt1-Oct-09 17:21 
AnswerRe: FTP in vb.net Pin
Tom Deketelaere1-Oct-09 21:54
professionalTom Deketelaere1-Oct-09 21:54 
AnswerRe: FTP in vb.net Pin
Dave Kreskowiak2-Oct-09 4:00
mveDave Kreskowiak2-Oct-09 4:00 
QuestionDelegates confusion Pin
Sonhospa1-Oct-09 3:11
Sonhospa1-Oct-09 3:11 
Hello,

in my project I'm using a MDI window which holds a StatusStrip, containing Label and ProgressBar. When updating it from the BackgroundWorker of another form I get an InvalidOperationException saying (translated from German) that, before an OLE call could be processed, I'd have to set STAThread mode for the current thread.

After experimenting a lot, I'm a bit desperate... not knowing where to set STAThread mode. Does probably someone have an idea what's wrong in the following?

Here's my code:
' Call the delegate from the subform:
 Private Sub BGWFileRead_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BGWFileRead.DoWork
     CollectFrames(BGWFileRead, AddressOf MDIMain.ShowProgress)                    <------ here's where the exception is thrown
 End Sub

 Private Sub CollectFrames(ByVal bgw As BackgroundWorker, ByVal Handler As ShowProgressDelegate)
     .. (other stuff) ..
     If Handler IsNot Nothing Then
         Dim ProcessMessage As String = New String(String.Format("Loading file {0} ({1} of {2})", thisFrame.FileToRead.Name, SoFar, Frames.Size))
         Handler.Invoke(CLng(Frames.Size), SoFar, thisFrame.FileToRead.Name, ProcessMessage, ExecutionTime)
     End If
 End Sub

' Main MDI form:
 Public Delegate Sub ShowProgressDelegate(ByVal Files As Long, ByVal TotalFiles As Long, ByVal filename As String, ByVal Message As String, ByVal Time As Integer)

 Public Sub ShowProgress(ByVal Total As Long, ByVal SoFar As Long, ByVal file As String, ByVal Message As String, ByVal Timespan As Integer)
     If Me.InvokeRequired Then
         Dim SPdeleg As New ShowProgressDelegate(AddressOf ShowProgress)
         Me.BeginInvoke(SPdeleg, New Object() {Total, SoFar, file, Message, Timespan})
     Else
         ' actualize StatusStrip
         Dim percent As Integer = CInt((SoFar / Total) * 100)
         Me.StatusProgressBar.Value = percent
         Me.StatusLabel.Text = Message
     End If
 End Sub

Thanks in advance for your input!

Michael
AnswerRe: Delegates confusion Pin
Luc Pattyn1-Oct-09 3:44
sitebuilderLuc Pattyn1-Oct-09 3:44 
GeneralRe: Delegates confusion Pin
Sonhospa1-Oct-09 4:22
Sonhospa1-Oct-09 4:22 
GeneralRe: Delegates confusion Pin
Luc Pattyn1-Oct-09 4:34
sitebuilderLuc Pattyn1-Oct-09 4:34 
QuestionNeed help with Parsing Pin
Hawkster181-Oct-09 3:10
Hawkster181-Oct-09 3:10 
AnswerRe: Need help with Parsing Pin
Luc Pattyn1-Oct-09 3:47
sitebuilderLuc Pattyn1-Oct-09 3:47 
GeneralRe: Need help with Parsing Pin
Hawkster181-Oct-09 3:53
Hawkster181-Oct-09 3:53 
GeneralRe: Need help with Parsing Pin
Hawkster181-Oct-09 3:59
Hawkster181-Oct-09 3:59 
GeneralRe: Need help with Parsing Pin
Luc Pattyn1-Oct-09 4:04
sitebuilderLuc Pattyn1-Oct-09 4:04 
AnswerRe: Need help with Parsing Pin
Dave Kreskowiak1-Oct-09 3:49
mveDave Kreskowiak1-Oct-09 3:49 
GeneralRe: Need help with Parsing Pin
Hawkster181-Oct-09 3:57
Hawkster181-Oct-09 3:57 
GeneralRe: Need help with Parsing Pin
Dave Kreskowiak1-Oct-09 3:59
mveDave Kreskowiak1-Oct-09 3:59 
GeneralRe: Need help with Parsing Pin
Hawkster181-Oct-09 4:04
Hawkster181-Oct-09 4:04 
GeneralRe: Need help with Parsing Pin
Dave Kreskowiak1-Oct-09 4:48
mveDave Kreskowiak1-Oct-09 4:48 
QuestionCopy Fail Pin
Vijjuuu.1-Oct-09 2:21
Vijjuuu.1-Oct-09 2:21 
AnswerRe: Copy Fail Pin
Dave Kreskowiak1-Oct-09 3:43
mveDave Kreskowiak1-Oct-09 3:43 
GeneralRe: Copy Fail Pin
Vijjuuu.1-Oct-09 4:19
Vijjuuu.1-Oct-09 4:19 
QuestionReplicate Application Network Behaviour Pin
phil241530-Sep-09 23:54
phil241530-Sep-09 23:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.