public static void SetCredentials(string btc, string worker) { var data = new NicehashCredentials { btc = btc, worker = worker }; if (BitcoinAddress.ValidateBitcoinAddress(data.btc) && BitcoinAddress.ValidateWorkerName(worker)) { var sendData = JsonConvert.SerializeObject(data); // Send as task since SetCredentials is called from UI threads Task.Factory.StartNew(() => _socket?.SendData(sendData)); } }