private static async Task <string> GetEventListAsync(Socket socket, IPAddress ip) { byte[] buffer = CreateEventListRequest(ip); await SocketHelper.SendAsync(socket, buffer); SocketAsyncEventArgs saea = await SocketHelper.ReceiveAsync(socket); return(Encoding.ASCII.GetString(saea.Buffer, 0, saea.BytesTransferred)); }
public async Task <bool> InitializeAsync() { SocketAsyncEventArgs args = await SocketHelper.ConnectAsync(_socket, _remoteEndPoint); if (args.LastOperation != SocketAsyncOperation.Connect) { return(false); } string data = await GetEventListAsync(_socket, _remoteEndPoint.Address); ReadBoldSettings(data); _backgroundWorker.DoWork += BackgroundWorker_DoWork; _backgroundWorker.RunWorkerCompleted += BackgroundWorker_RunWorkerCompleted; _backgroundWorker.RunWorkerAsync(); return(IsInitialized = true); }