Forum Xamarin.Android

Thread - Notify() and get back to the main activty/ thread

AlonAvivAlonAviv USMember ✭✭

Hi there,
I'm having some problems using thread and async methods.
I tried doing a simple socket connection and after failing to use async and await keywords I just used a thread. My code looks like this:
Thread t = new Thread(() =>
//Socket socket1 = new Socket();
Socket server = new Socket ("", 13137);
socket1.ConnectAsync (server.RemoteSocketAddress);
This is the client code. The connection is being made and I can get to the client from the server. The problem is that the client is stuck on this thread and can't get forward. even though I tried adding "notify()" inside/outside the thread.

Thanks a lot, Alon.


  • MihaMarkicMihaMarkic SI ✭✭✭✭

    Doesn't the code below work?
    What Socket are you using?

    Socket server = new Socket ("", 13137);
    await socket1.ConnectAsync (server.RemoteSocketAddress);
  • AlonAvivAlonAviv USMember ✭✭

    cannot await a void (because of the connectAsync method).
    Also tried manipulate into Task version but it didn't work.

Sign In or Register to comment.