当前位置: 首页>>代码示例>>C#>>正文


C# ISubscriber类代码示例

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


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


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