• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ISubscriber类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ISubscriber的典型用法代码示例。如果您正苦于以下问题:C# ISubscriber类的具体用法?C# ISubscriber怎么用?C# ISubscriber使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ISubscriber类属于命名空间,在下文中一共展示了ISubscriber类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            IPublisher publisher = new Publisher(countOfChannels, countOfSubscribers);
            IDataMediator dataMediator = (IDataMediator) publisher;

            ISubscriber[] subscribers = new ISubscriber[countOfSubscribers];
            for (int i = countOfSubscribers - 1; i >= 0; i--)
            {
                subscribers[i] = new Subscriber(publisher);
            }

            runSubscribe(subscribers, publisher);
            Thread.CurrentThread.Priority = ThreadPriority.Highest;

            for (int i = 0; i < 1000; i++)
            {
                Stopwatch latency = Stopwatch.StartNew();

                int onLoadSubscribersCount = dataMediator.onLoad(randomBytes(10000), rnd.Next(countOfChannels));

                latency.Stop();
                Console.Write("latency is\t" + latency.Elapsed.Milliseconds + "\tfor\t" + onLoadSubscribersCount + "\tsubscribers");
                Console.WriteLine();

            }

            Console.WriteLine("thats all");
            Console.ReadLine();
        }
开发者ID:tasque,项目名称:publisher-subscribers-test-app,代码行数:29,代码来源:Program.cs


示例2: SetupMessaging

 public void SetupMessaging(ISubscriber mainBus)
 {
     mainBus.Subscribe<SystemMessage.StateChangeMessage>(_projectionManager);
     if (_runProjections >= RunProjections.System)
     {
         mainBus.Subscribe<ProjectionManagementMessage.Post>(_projectionManager);
         mainBus.Subscribe<ProjectionManagementMessage.UpdateQuery>(_projectionManager);
         mainBus.Subscribe<ProjectionManagementMessage.GetQuery>(_projectionManager);
         mainBus.Subscribe<ProjectionManagementMessage.Delete>(_projectionManager);
         mainBus.Subscribe<ProjectionManagementMessage.GetStatistics>(_projectionManager);
         mainBus.Subscribe<ProjectionManagementMessage.GetState>(_projectionManager);
         mainBus.Subscribe<ProjectionManagementMessage.GetResult>(_projectionManager);
         mainBus.Subscribe<ProjectionManagementMessage.Disable>(_projectionManager);
         mainBus.Subscribe<ProjectionManagementMessage.Enable>(_projectionManager);
         mainBus.Subscribe<ProjectionManagementMessage.Abort>(_projectionManager);
         mainBus.Subscribe<ProjectionManagementMessage.SetRunAs>(_projectionManager);
         mainBus.Subscribe<ProjectionManagementMessage.Reset>(_projectionManager);
         mainBus.Subscribe<ProjectionManagementMessage.StartSlaveProjections>(_projectionManager);
         mainBus.Subscribe<ProjectionManagementMessage.RegisterSystemProjection>(_projectionManager);
         mainBus.Subscribe<ProjectionManagementMessage.Internal.CleanupExpired>(_projectionManager);
         mainBus.Subscribe<ProjectionManagementMessage.Internal.RegularTimeout>(_projectionManager);
         mainBus.Subscribe<ProjectionManagementMessage.Internal.Deleted>(_projectionManager);
         mainBus.Subscribe<ProjectionManagementMessage.RegisterSystemProjection>(_projectionManager);
         mainBus.Subscribe<CoreProjectionManagementMessage.Started>(_projectionManager);
         mainBus.Subscribe<CoreProjectionManagementMessage.Stopped>(_projectionManager);
         mainBus.Subscribe<CoreProjectionManagementMessage.Faulted>(_projectionManager);
         mainBus.Subscribe<CoreProjectionManagementMessage.Prepared>(_projectionManager);
         mainBus.Subscribe<CoreProjectionManagementMessage.StateReport>(_projectionManager);
         mainBus.Subscribe<CoreProjectionManagementMessage.ResultReport>(_projectionManager);
         mainBus.Subscribe<CoreProjectionManagementMessage.StatisticsReport>(_projectionManager);
         mainBus.Subscribe<CoreProjectionManagementMessage.SlaveProjectionReaderAssigned>(_projectionManager);
     }
     mainBus.Subscribe<ClientMessage.WriteEventsCompleted>(_projectionManager);
     mainBus.Subscribe<ClientMessage.ReadStreamEventsBackwardCompleted>(_projectionManager);
 }
开发者ID:jjoergensen,项目名称:EventStore,代码行数:35,代码来源:ProjectionManagerNode.cs


示例3: Remove

 public void Remove(ISubscriber subscriber)
 {
     if (subscribers.ContainsKey(subscriber.GetType()))
     {
         subscribers.Remove(subscriber.GetType());
     }
 }
开发者ID:rexwhitten,项目名称:Siege,代码行数:7,代码来源:SubscriberCollectionItem.cs


示例4: Subscribe

 public void Subscribe(ISubscriber subscriber)
 {
     if (!_subscribers.Contains(subscriber))
     {
         _subscribers.Add(subscriber);
     }
 }
开发者ID:Sp1n89,项目名称:Internship2015,代码行数:7,代码来源:YouTubeChannel.cs


示例5: getInitialArray

 void IPublisher.subscribe(ISubscriber subscriber, IList<int> channelsToSubscribe)
 {
     int[] subscribedChannels = subscriberChannels.GetOrAdd(subscriber, getInitialArray(this.channelsCapacity));
     foreach (var channel in channelsToSubscribe)
     {
         if (0 <= channel && channel < channelSubscribers.Length - 1 && subscribedChannels[channel] == -1)
         {
             for (int i = 0; i < this.subscribersCapacity; i++)
             {
                 if (channelSubscribers[channel][i] == null)
                 {
                     locks[channel][i].EnterWriteLock();
                     try
                     {
                         subscribedChannels[channel] = channel;
                         if (channelSubscribers[channel][i] == null)
                         {
                             channelSubscribers[channel][i] = subscriber;
                             break;
                         }
                     }
                     finally
                     {
                         locks[channel][i].ExitWriteLock();
                     }
                 }
             }
         }
     }
 }
开发者ID:tasque,项目名称:publisher-subscribers-test-app,代码行数:30,代码来源:Publisher.cs


示例6: Add

 public void Add(ISubscriber subscriber)
 {
     if (!subscribers.ContainsKey(subscriber.GetType()))
     {
         subscribers.Add(subscriber.GetType(), subscriber);
     }
 }
开发者ID:rexwhitten,项目名称:Siege,代码行数:7,代码来源:SubscriberCollectionItem.cs


示例7: UnSubscribe

 public void UnSubscribe(ISubscriber subscriber)
 {
     if (_subscribers.Contains(subscriber))
     {
         _subscribers.Remove(subscriber);
     }
 }
开发者ID:Sp1n89,项目名称:Internship2015,代码行数:7,代码来源:YouTubeChannel.cs


示例8: LunchFilter

 public LunchFilter(IFiber fiber,
     ISubscriber<SimpleYouTubeClip> input,
     IPublisher<SimpleYouTubeClip> output)
 {
     this.output = output;
     this.subscription  = input.Subscribe(fiber, NewClip);
 }
开发者ID:rix0rrr,项目名称:SiouxTube,代码行数:7,代码来源:LunchFilter.cs


示例9: EventStoreEmbeddedNodeConnection

        public EventStoreEmbeddedNodeConnection(ConnectionSettings settings, string connectionName, IPublisher publisher, ISubscriber bus, IAuthenticationProvider authenticationProvider)
        {
            Ensure.NotNull(publisher, "publisher");
            Ensure.NotNull(settings, "settings");

            Guid connectionId = Guid.NewGuid();

            _settings = settings;
            _connectionName = connectionName;
            _publisher = publisher;
            _authenticationProvider = authenticationProvider;
            _subscriptionBus = new InMemoryBus("Embedded Client Subscriptions");
            _subscriptions = new EmbeddedSubscriber(_subscriptionBus, _authenticationProvider, _settings.Log, connectionId);
            
            _subscriptionBus.Subscribe<ClientMessage.SubscriptionConfirmation>(_subscriptions);
            _subscriptionBus.Subscribe<ClientMessage.SubscriptionDropped>(_subscriptions);
            _subscriptionBus.Subscribe<ClientMessage.StreamEventAppeared>(_subscriptions);
            _subscriptionBus.Subscribe<ClientMessage.PersistentSubscriptionConfirmation>(_subscriptions);
            _subscriptionBus.Subscribe<ClientMessage.PersistentSubscriptionStreamEventAppeared>(_subscriptions);
            _subscriptionBus.Subscribe(new AdHocHandler<ClientMessage.SubscribeToStream>(_publisher.Publish));
            _subscriptionBus.Subscribe(new AdHocHandler<ClientMessage.UnsubscribeFromStream>(_publisher.Publish));
            _subscriptionBus.Subscribe(new AdHocHandler<ClientMessage.ConnectToPersistentSubscription>(_publisher.Publish));

            bus.Subscribe(new AdHocHandler<SystemMessage.BecomeShutdown>(_ => Disconnected(this, new ClientConnectionEventArgs(this, new IPEndPoint(IPAddress.None, 0)))));
        }
开发者ID:danieldeb,项目名称:EventStore,代码行数:25,代码来源:EventStoreEmbeddedNodeConnection.cs


示例10: Subscribe

 public void Subscribe(ISubscriber subscriber)
 {
     if(_subscribers.Contains(subscriber) == false)
     {
         _subscribers.Add(subscriber);
     }
 }
开发者ID:henceee,项目名称:1DV607-1,代码行数:7,代码来源:Player.cs


示例11: TestMassivePublish

        private void TestMassivePublish(ISubscriber conn, string caption)
        {
            const int loop = 100000;

            GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
            GC.WaitForPendingFinalizers();

            var tasks = new Task[loop];

            var withFAF = Stopwatch.StartNew();
            for (int i = 0; i < loop; i++)
                conn.Publish("foo", "bar", CommandFlags.FireAndForget);
            withFAF.Stop();

            GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
            GC.WaitForPendingFinalizers();

            var withAsync = Stopwatch.StartNew();
            for (int i = 0; i < loop; i++)
                tasks[i] = conn.PublishAsync("foo", "bar");
            conn.WaitAll(tasks);
            withAsync.Stop();

            Assert.Less(1, 2, "sanity check");
            Assert.Less(withFAF.ElapsedMilliseconds, withAsync.ElapsedMilliseconds, caption);
            Console.WriteLine("{2}: {0}ms (F+F) vs {1}ms (async)",
                withFAF.ElapsedMilliseconds, withAsync.ElapsedMilliseconds, caption);
        }
开发者ID:BiYiTuan,项目名称:StackExchange.Redis,代码行数:28,代码来源:PubSub.cs


示例12: MainWindow

        public MainWindow(ISubscriber<PlayerCommand> commandChannel, IPublisher<RichYouTubeClip> finishedChannel)
        {
            InitializeComponent();
            this.finishedChannel = finishedChannel;

            finishedTimer = new Timer(TimerExpired);

            progressTimer = new System.Timers.Timer(1000);
            progressTimer.AutoReset = true;
            progressTimer.Elapsed += new System.Timers.ElapsedEventHandler(progressTimer_Elapsed);

            var fiber     = new DispatcherFiber(Dispatcher);
            commandChannel.Subscribe(fiber, OnPlayerCommand);
            fiber.Start();

            WindowStyle = WindowStyle.None;
            WindowState = WindowState.Maximized;
            ShowInTaskbar = false;

            Cursor = Cursors.None;
            try
            {
                tv.Initialize();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error initialize remote control", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
开发者ID:rix0rrr,项目名称:SiouxTube,代码行数:29,代码来源:MainWindow.xaml.cs


示例13: Register

 public void Register(
     TFChunkDb db, QueuedHandler mainQueue, ISubscriber mainBus, TimerService timerService,
     ITimeProvider timeProvider, IHttpForwarder httpForwarder, HttpService[] httpServices, IPublisher networkSendService)
 {
     _projections = new EventStore.Projections.Core.Projections(
         db, mainQueue, mainBus, timerService, timeProvider, httpForwarder, httpServices, networkSendService,
         projectionWorkerThreadCount: _projectionWorkerThreadCount, runProjections: _runProjections);
 }
开发者ID:jjvdangelo,项目名称:EventStore,代码行数:8,代码来源:Projections.cs


示例14: PlaylistController

 public PlaylistController(IFiber fiber,
     ISubscriber<RichYouTubeClip> newClips,
     ISubscriber<RichYouTubeClip> finishedPlaying,
     IPublisher<PlayerCommand> playerCommands)
 {
     this.playerCommands = playerCommands;
     this.newClipSubscription  = newClips.Subscribe(fiber, NewClip);
     this.finishedSubscription = finishedPlaying.Subscribe(fiber, Finished);
 }
开发者ID:rix0rrr,项目名称:SiouxTube,代码行数:9,代码来源:PlaylistController.cs


示例15: RedisSubscriberTests

        public RedisSubscriberTests()
        {
            _subscriber = A.Fake<ISubscriber>();
            _remoteCache = A.Fake<ICacheAside>();
            _itemSerializer = A.Fake<IItemSerializer>();

            _connection = A.Fake<IConnectionMultiplexer>();
            A.CallTo(() => _connection.GetSubscriber(A<object>._)).Returns(_subscriber);
        }
开发者ID:avieru,项目名称:DoubleCache,代码行数:9,代码来源:RedisSubscriberTests.cs


示例16: RedisConnection

        public RedisConnection(IDatabase redis, ISubscriber subscriber, string jobStorageIdentity)
        {
            _subscriber = subscriber;
            _jobStorageIdentity = jobStorageIdentity;
            Redis = redis;
            mre = new ManualResetEvent(false);

            _subscriber.Subscribe(string.Format("{0}JobFetchChannel", RedisStorage.Prefix), (channel, val) => { mre.Set();});
        }
开发者ID:xyting,项目名称:Hangfire.Redis.StackExchange,代码行数:9,代码来源:RedisConnection.cs


示例17: Projections

        public Projections(
            TFChunkDb db, QueuedHandler mainQueue, ISubscriber mainBus, TimerService timerService, ITimeProvider timeProvider,
            IHttpForwarder httpForwarder, HttpService[] httpServices, IPublisher networkSendQueue,
            int projectionWorkerThreadCount, RunProjections runProjections)
        {
            _projectionWorkerThreadCount = projectionWorkerThreadCount;
            SetupMessaging(
                db, mainQueue, mainBus, timerService, timeProvider, httpForwarder, httpServices, networkSendQueue,
                runProjections);

        }
开发者ID:jjoergensen,项目名称:EventStore,代码行数:11,代码来源:Projections.cs


示例18: RedisSubscribe

        public RedisSubscribe(ISubscriber Subscriber, string Prefix)
        {
            Channel = Prefix + "announce";
            _Subscriber = Subscriber;
            _Event = new ManualResetEvent(false);

            _Subscriber.Subscribe(Channel, delegate
            {
                _Event.Set();
            });
        }
开发者ID:okusnadi,项目名称:Hangfire.Redis.StackExchange,代码行数:11,代码来源:RedisSubscribe.cs


示例19: RemoveAll

 public void RemoveAll(ISubscriber subscriber)
 {
     lock (_registering)
     {
         RegistryEntry entry;
         if (_bySubscriber.TryGetValue(subscriber, out entry))
         {
             _byGuid.Remove(entry.Guid);
             removeByType(entry);
         }
     }
 }
开发者ID:lcorneliussen,项目名称:Braindrops,代码行数:12,代码来源:SubscriptionRegistry.cs


示例20: PersistentSubscriptionConsumerStrategyRegistry

        public PersistentSubscriptionConsumerStrategyRegistry(IPublisher mainQueue, ISubscriber mainBus, IPersistentSubscriptionConsumerStrategyFactory[] additionalConsumerStrategies)
        {
            _mainQueue = mainQueue;
            _mainBus = mainBus;
            Register(new DelegatePersistentSubscriptionConsumerStrategyFactory(SystemConsumerStrategies.RoundRobin, (subId, queue, bus) => new RoundRobinPersistentSubscriptionConsumerStrategy()));
            Register(new DelegatePersistentSubscriptionConsumerStrategyFactory(SystemConsumerStrategies.DispatchToSingle, (subId, queue, bus) => new DispatchToSinglePersistentSubscriptionConsumerStrategy()));
            Register(new DelegatePersistentSubscriptionConsumerStrategyFactory(SystemConsumerStrategies.Pinned, (subId, queue, bus) => new PinnedPersistentSubscriptionConsumerStrategy(new XXHashUnsafe())));

            foreach (var consumerStrategyFactory in additionalConsumerStrategies)
            {
                Register(consumerStrategyFactory);
            }
        }
开发者ID:danieldeb,项目名称:EventStore,代码行数:13,代码来源:PersistentSubscriptionConsumerStrategyRegistry.cs



注:本文中的ISubscriber类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ISubscription类代码示例发布时间:2022-05-24
下一篇:
C# ISubject类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap