Recently I was working on a project and everything was fine while debugging but after I create setup and installed the project I Got "System.Runtime.InteropServices.ExternalException (0x80004005): GDI+..." error. I figured out that the error probably caused by codes that like:
My.Resources.MyImage.Save(Application.Startuppath + "/Example.png")
or/and
Sub Example()
if My.Settings.PortBusy = False Then
dim t1 as new threading.thread(addressof IsPortOpen)
t1.start
My.Settings.PortBusy = True
End If
End Sub
.
.
.
Function operaport() As Boolean
Dim Client As TcpClient = Nothing
Try
Client = New TcpClient("127.0.0.1", 9223)
Return True
Catch ex As SocketException
Return False
Finally
If Not Client Is Nothing Then
Client.Close()
End If
End Try
End Function
Sub IsPortOpen()
Dim brvpt As Boolean = brvport()
Dim gecpt As Boolean = geckoport()
Dim cpt As Boolean = chromeport()
Dim opt As Boolean = operaport()
If brvpt = True Or gecpt = True Or cpt = True Or opt = True Then
PortStatus.Checked = True
Else
PortStatus.Checked = False
End If
My.Settings.PortBusy = False
End Sub
Instead these I Used
Dim copy As Image = My.Resources.MyImage
copy.Save(Application.Startuppath + "/Example.png")
and
PortStatus.InvokeSafe(New shit(AddressOf IsPortOpen))
But there is another "Threading.Thread" task and it interacts with multiple UI Objects. So how can I "InvokeSafe" multiple Objects in order to use multi-threading tasks that interacts with more than one Object?
Thank You so much For Reading :) .
This question is a mess but, if I'm getting the gist correctly, you just need to pass a delegate to InvokeSafe
for a method that interacts with your multiple UI objects. I'm guessing that InvokeSafe
is an extension method that tests the InvokeRequired
property and calls the Invoke
method of the control you call it on. I have to guess because you haven't bothered to explain. In that case, it doesn't matter what control you call it on. The point of those members is to ensure that you execute code on the thread that owns the specific control. That is going to be the same thread for every form and control, so it matters not which you control you use to get to that thread.
User contributions licensed under CC BY-SA 3.0