public async Task <bool> DoWork(LockOper oper) { try { // if (this.table == null) return false; // return this.table.GetQueue(oper.Key).LockNoWait(oper.Session, LockType.Read); return(true); } catch { return(false); } }
public async Task <object> BeginRequest(LockOper command) { string data = Newtonsoft.Json.JsonConvert.SerializeObject(command); var leader = Nodes.Where(r => ((HttpRaftServiceNode)r).IsLeader()) .Select(r => (HttpRaftServiceNode)r).FirstOrDefault(); if (leader == null) { return("null"); } //Console.WriteLine("start lock oper" + DateTime.Now.Second + ":" + DateTime.Now.Millisecond); var result = await Task.Run(async() => { var result = await((RaftServiceNode)leader).AddLogEntryRequestAsync(System.Text.Encoding.UTF8.GetBytes(data)).ConfigureAwait(false); return(result); } ); // Console.WriteLine("await finished" + DateTime.Now.Second + ":" + DateTime.Now.Millisecond); return(result); }