Fix ThreadStateException.

This commit is contained in:
Riley McArdle
2011-06-05 00:30:04 -05:00
parent bfb137c442
commit 04dbfb2bf4
9 changed files with 11 additions and 6 deletions

View File

@@ -711,6 +711,7 @@ Namespace App
_LoadUpdate = True
Dim t As New Thread(AddressOf LoadConnectionsBGd)
t.SetApartmentState(Threading.ApartmentState.STA)
t.Start()
End Sub
@@ -1081,6 +1082,7 @@ Namespace App
_SaveUpdate = True
Dim t As New Thread(AddressOf SaveConnectionsBGd)
t.SetApartmentState(Threading.ApartmentState.STA)
t.Start()
End Sub

View File

@@ -98,6 +98,7 @@ Namespace Connection
Public Overridable Sub Close()
Dim t As New Thread(AddressOf CloseBG)
t.SetApartmentState(Threading.ApartmentState.STA)
t.IsBackground = True
t.Start()
End Sub

View File

@@ -62,6 +62,7 @@ Namespace Tools
Public Shared Event SQLUpdateCheckFinished(ByVal UpdateAvailable As Boolean)
Public Shared Sub IsSQLUpdateAvailableBG()
Dim t As New Threading.Thread(AddressOf IsSQLUpdateAvailable)
t.SetApartmentState(Threading.ApartmentState.STA)
t.Start()
End Sub

View File

@@ -395,6 +395,7 @@ Namespace Tools
Public Sub StartScan()
sThread = New Thread(AddressOf StartScanBG)
sThread.SetApartmentState(Threading.ApartmentState.STA)
sThread.IsBackground = True
sThread.Start()
End Sub

View File

@@ -67,8 +67,8 @@ Namespace UI
Public Sub CheckForAnnouncement()
Try
uT = New Thread(AddressOf CheckForAnnouncementBG)
uT.SetApartmentState(ApartmentState.STA)
uT.IsBackground = True
'uT.SetApartmentState(ApartmentState.STA)
If Me.IsAnnouncementCheckHandlerDeclared = False Then
AddHandler AnnouncementCheckCompleted, AddressOf AnnouncementCheckComplete

View File

@@ -1278,6 +1278,7 @@ Namespace UI
Me.btnHostStatus.Tag = "checking"
HostName = TryCast(ConnectionInfo, mRemoteNG.Connection.Info).Hostname
pThread = New Threading.Thread(AddressOf CheckHostAlive)
pThread.SetApartmentState(Threading.ApartmentState.STA)
pThread.IsBackground = True
pThread.Start()
Catch ex As Exception

View File

@@ -395,9 +395,8 @@ Namespace UI
RemoteFile = Me.txtRemoteFile.Text
Dim t As New Thread(AddressOf StartTransferBG)
t.IsBackground = True
t.SetApartmentState(ApartmentState.STA)
t.IsBackground = True
t.Start()
Catch ex As Exception
mC.AddMessage(Messages.MessageClass.ErrorMsg, My.Resources.strSSHTransferFailed & vbNewLine & ex.Message)

View File

@@ -355,8 +355,8 @@ Namespace UI
tDomain = Domain
threadSessions = New Threading.Thread(AddressOf GetSessionsBG)
threadSessions.IsBackground = True
threadSessions.SetApartmentState(Threading.ApartmentState.STA)
threadSessions.IsBackground = True
threadSessions.Start()
Catch ex As Exception
mC.AddMessage(Messages.MessageClass.ErrorMsg, "GetSessions (UI.Window.Sessions) failed" & vbNewLine & ex.Message, True)
@@ -398,8 +398,8 @@ Namespace UI
tSessionID = SessionID
threadSessions = New Threading.Thread(AddressOf KillSessionBG)
threadSessions.IsBackground = True
threadSessions.SetApartmentState(Threading.ApartmentState.STA)
threadSessions.IsBackground = True
threadSessions.Start()
Catch ex As Exception
mC.AddMessage(Messages.MessageClass.ErrorMsg, "KillSession (UI.Window.Sessions) failed" & vbNewLine & ex.Message, True)

View File

@@ -217,8 +217,8 @@ Namespace UI
Public Sub CheckForUpdate()
Try
uT = New Thread(AddressOf CheckForUpdateBG)
uT.SetApartmentState(ApartmentState.STA)
uT.IsBackground = True
'uT.SetApartmentState(ApartmentState.STA)
If Me.IsUpdateCheckHandlerDeclared = False Then
AddHandler UpdateCheckCompleted, AddressOf UpdateCheckComplete