/// <summary> /// Cancel the subscriber's listening and remove it from the dictionary so that GC can reclaim the resources it occupies /// </summary> public async Task RemoveAsync(IMessageSubscriber messageSubscriber) { CheckValue.NotNull(messageSubscriber, nameof(messageSubscriber)); //if no result,return completed directly. if (!_subscriberDic.TryGetValue(messageSubscriber, out _)) { await messageSubscriber.DisposeAsync(); } _subscriberDic.TryRemove(messageSubscriber, out _); await messageSubscriber.DisposeAsync(); }