public Task StoreChatHistoryAsync(Say say) { return Task.Run(async () => { await storeHistorySemaphore.WaitAsync(); try { using (var db = new ZkDataContext()) { var historyEntry = new LobbyChatHistory(); historyEntry.SetFromSay(say); db.LobbyChatHistories.Add(historyEntry); db.SaveChanges(); } } catch (Exception ex) { Trace.TraceError("Error saving chat history: {0}", ex); } finally { storeHistorySemaphore.Release(); } }); }
public async Task StoreChatHistory(Say say) { using (var db = new ZkDataContext()) { var historyEntry = new LobbyChatHistory(); historyEntry.SetFromSay(say); db.LobbyChatHistories.Add(historyEntry); await db.SaveChangesAsync(); } }