public void Clear() { EnsureNotDisposed(); EnsureWriteAccess(); T someItem; while (!_list.IsEmpty) { _list.TryTake(out someItem); } }
public static void PublishMessage(Models.NotificationMessage msg) { foreach (var subscriberInfo in _subscribers) { try { string jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(msg); subscriberInfo.Stream.Write("event: message\n"); subscriberInfo.Stream.Write("data:" + jsonString + "\n\n"); subscriberInfo.Stream.FlushAsync(); } catch (Exception) { SubscriberInfo ignore; ignore = subscriberInfo; _subscribers.TryTake(out ignore); } } }