Suraj Singh
Suraj Singh

Reputation: 5

Unable to set error provider in threading

I have been using errorprovider in VB.Net windows form, which was working fine. How ever I noticed, if I try to set errorprovider seterror method in procedure that was called via threading, the error provider doesn't work.

Is there something I m missing while starting the thread?

My Code:

Dim thrdd1 As New Thread(AddressOf random_procedure)
thrdd1.IsBackground = True
thrdd1.Start()

Privavte Sub random_procedure()

    *do some events*

    seterrorprovider()

End Sub

Private sub seterrorprovider()

    errorpro1.seterror(textbox1,"Unable to load")

End Sub

Upvotes: -4

Views: 150

Answers (2)

Suraj Singh
Suraj Singh

Reputation: 5

Found the issue, it was just another illegalcrossthreadcalls. Wasn't able to track it because I have set it to false in formload. Made a sub with invoke to change text of main UI thread. Thanks to anyone who tried helping

Upvotes: 0

yangfang
yangfang

Reputation: 1

Public Sub New()

    ' This call is required by the designer。
    InitializeComponent()

    ' Add any initialization after the InitializeComponent() call。
    CheckForIllegalCrossThreadCalls = False

End Sub

Add this Code in your UI form ,maybe solve your problem.

Upvotes: -4

Related Questions