|
-
Mar 23rd, 2023, 06:49 AM
#3
Re: Correct way to "MethodInvoke" on Option Strict
You clearly still haven't paid attention to what you were told if you're asking this question at all. The whole point of the BackgroundWorker is so that you can just call methods and handle events, just as you always do, rather than using Invoke at all. I provided you with a link to a thread that explains how to use a BackgroundWorker and, in that thread, i specific explain and demonstrate that, if you want to update the UI during the background work, you call ReportProgress and handle the ProgressChanged event. Why even ask for help if you're just going to ignore it when it's provided?
If you were going to use Invoke, which you shouldn't if you're using BackgroundWorker, then lambdas follow the sane rules as named methods: a Function returns a value and a Sub doesn't. This:
vb.net Code:
Me.Convtxt.Invoke(New MethodInvoker(Function()
Convtxt.AppendText("YOU: " + RECEIVE + vbNewLine)
End Function))
would correctly be written like this:
vb.net Code:
Me.Convtxt.Invoke(Sub() Convtxt.AppendText("YOU: " + RECEIVE + vbNewLine))
Of course, neither is the correct way to update the UI when using a BackgroundWorker.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|