Home > Net >  You can run the following code, but it is not the asynchronous operation. Why?
You can run the following code, but it is not the asynchronous operation. Why?

Time:09-15

 Private Sub BtnTcpTestYaxin_Click (sender As Object, e As RoutedEventArgs) Handles btnTcpTestYaxin. Click 
Me. BtnTcpTestYaxin. Dispatcher. The BeginInvoke (New Action (Sub ()
'thread.sleep (TimeSpan. FromSeconds (3))
The Debug. Print (" DDDDDDDDDDDDDDDDDDDDDDDDDDDDD ")
Dim uri200 the As System. Uri=New Uri (MySettings. Default. UrlYaxin200)
Dim uri250 the As System. Uri=New Uri (MySettings. Default. UrlYaxin250)
The Debug. Print (uri250. Host & amp; "... "& amp; Uri250. Port)
Dim ok250 As String=IIf (TcpBase TcpConnect (uri250. Host, uri250. Port), "250 ok" and "no" 250)
Dim ok200 As String=IIf (TcpBase TcpConnect (uri200. Host, uri200. Port), "200 ok" and "no" 200)
BtnTcpTestYaxin. The Content=ok250 & amp; VbCrLf & amp; Ok200
End Sub))

End Sub

CodePudding user response:

The entrusted still accounts for the main thread,

CodePudding user response:

Please make a suggestion

CodePudding user response:

WINFORM in asynchronous operation after me. Invoke call another program to modify the UI property, first write WPF asynchronous, don't quite understand

CodePudding user response:

reference 1/f, lover and response:
entrusted still accounts for the main thread,

The debug found thread. Currentthread and dispatcher is a process, wonder, the begininvoke and invoke is not the same

CodePudding user response:

The begininvoke and invoke are send entrusted to the main thread, such as the main line Cheng Youkong after only a hair in the past to dry is a hair in the past, just do it

CodePudding user response:

Oh, WPF to modify the UI, what is the most popular way? Data binding is control?

CodePudding user response:

reference 4 floor ytredear response:
Quote: reference 1/f, lover and response:
entrusted still accounts for the main thread,

The debug found thread. Currentthread and dispatcher is a process, wonder, the begininvoke and invoke is not the same as


Don't use entrust, open a new thread,

CodePudding user response:

reference 5 floor OrdinaryCoder reply:
the begininvoke and invoke are sent to the main thread, such as the main line Cheng Youkong after only a hair in the past to do a hair in the past do it directly

The problem is the both make the window gets stuck

CodePudding user response:

Tested a new thread, but a new thread to callback, like WINFORM, is depressed

CodePudding user response:

Guess from your code, you have to use a component does not support asynchronous thread, so even if you are in the child thread to call it, but it stuck - complete, waiting for the main thread to continue to run, this is redundant,

So in asynchronous multithreaded programming, can't call block statements, once in the call blocking statement is equivalent to "take off pants break wind" as well as to myself playing bad,
  • Related