Answer the question
In order to leave comments, you need to log in
How to run a cyclic (eternal) function in C# in a new thread?
There is a connection to the server via Websocket
var ws = new WebSocket("ws://localhost/client_websocket")
{
ws.OnOpen += (sender, e) => this.Connected();
ws.OnMessage += (sender, e) => Console.WriteLine(e.Data);
ws.OnError += (sender, e) =>//делаем что-то при ошибке
ws.OnClose += (sender, e) => //делаем что-то при отключении
ws.Connect();
while (true)
{
}
}
Answer the question
In order to leave comments, you need to log in
In the method declaration, immediately after the access modifier, type "async" and before the ws.Connect(); - await.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question