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


C# Dispatcher类代码示例

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


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

示例1: Attach

 public static void Attach()
 {
     AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
     dispatcher = Dispatcher.CurrentDispatcher;
     dispatcher.UnhandledException += CurrentDispatcher_UnhandledException;
     TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
 }
开发者ID:nagyist,项目名称:PlatformInstaller,代码行数:7,代码来源:ExceptionHandler.cs

示例2: Given

 public void Given()
 {
     _operation = new FailOnceOperation();
     _invoker = new OperationInvoker<string>(_operation);
     _invoker.Policies.Add(new Retry(null));
     _engine = new Dispatcher<string>();
 }
开发者ID:rajeshgupthar,项目名称:objectflow,代码行数:7,代码来源:WhenExecutingInvokerWithPolicy.cs

示例3: LightClawSynchronizationContext

        public LightClawSynchronizationContext(Dispatcher dispatcher, DispatcherPriority priority)
        {
            Contract.Requires<ArgumentNullException>(dispatcher != null);

            this.dispatcher = dispatcher;
            this.priority = priority;
        }
开发者ID:ScianGames,项目名称:Engine,代码行数:7,代码来源:LightClawSynchronizationContext.cs

示例4: FinalizeWorkDispatcher

 private static void FinalizeWorkDispatcher(Dispatcher dispatcher)
 {
     if (dispatcher != null)
     {
         dispatcher.Dispose();
     }
 }
开发者ID:ReactiveServices,项目名称:ReactiveServices.Application,代码行数:7,代码来源:StepsExecutor.cs

示例5: Dispatcher

 public Dispatcher()
 {
     Debug.Assert(_instance == null);
     _instance = this;
     _thread = new Thread(run);
     _thread.Start();
 }
开发者ID:externl,项目名称:ice,代码行数:7,代码来源:Dispatcher.cs

示例6: ViewModel

        /// <summary>
        /// Constructor.
        /// </summary>
        public ViewModel(Dispatcher uiDispatcher, string baseContentDir, Isometry iso)
        {
            //  Reference to the UIDispatcher for thread-safe collection manipulation
            _uiDispatcher = uiDispatcher;

            Factions = new ObservableCollection<FactionList> { new FactionList("AI"), new FactionList("Player 1"), new FactionList("Player 2") };
            
            //  Map setup
            Map = new MapDefinition(new ZTile(baseContentDir + "tiles\\Generic Tiles\\Generic Floors\\DirtSand\\Waste_Floor_Gravel_SandDirtCentre_F_1_NE.til"), iso, baseContentDir);
            MapCanvas = new MapCanvas(Map, uiDispatcher, baseContentDir + "tiles\\", iso, Factions);
            _useAltEditLayer = false;


            //  Create the available TileSets and collection views
            TileSets = new Dictionary<string, ObservableCollection<ZTile>>();
            TileSetViews = new Dictionary<string, ListCollectionView>();
            foreach (var di in new DirectoryInfo(baseContentDir + "tiles\\").GetDirectories())
            {
                TileSets.Add(di.Name, new ObservableCollection<ZTile>());
                TileSetViews.Add(di.Name, new ListCollectionView(TileSets[di.Name]));
            }

            //  Start a new thread to load in the tile images
            ThreadPool.QueueUserWorkItem(GetWholeTileSet, baseContentDir + "tiles\\");
        }
开发者ID:jo215,项目名称:Iso,代码行数:28,代码来源:ViewModel.cs

示例7: ConnectInternal

        private static async Task<IClient> ConnectInternal(ConnectionParams connectionParams, CancellationToken cancellationToken, Dispatcher dispatcher, CancellationTokenSource apiCancellationTokenSource)
        {
            try
            {
                var stream = await SetupConnection(connectionParams.HostName, connectionParams.Port);
                var fieldsStream = new FieldsStream(stream);
                var serializer = new IBSerializer();
                await Handshake(connectionParams.ClientId, fieldsStream, serializer, cancellationToken);

                var connection = new Connection.Connection(fieldsStream, serializer);
                var factory = new ApiObjectsFactory(connection, new IdsDispenser(connection), dispatcher, apiCancellationTokenSource);
                var waitForMarketConnected = factory.CreateWaitForMarketConnectedOperation(cancellationToken);
                var waitForAccountsList = factory.CreateReceiveManagedAccountsListOperation(cancellationToken);

                connection.ReadMessagesAndDispatch();

                await waitForMarketConnected;
                var accountStorage = await factory.CreateAccountStorageOperation(await waitForAccountsList, cancellationToken);
                return factory.CreateClient(accountStorage);
            }
            catch
            {
                apiCancellationTokenSource.Cancel();
                throw;
            }
        }
开发者ID:qadmium,项目名称:ibapi,代码行数:26,代码来源:ConnectionFactory.cs

示例8: ShouldExecuteFunction

        public void ShouldExecuteFunction()
        {
            var engine = new Dispatcher<string>();
            engine.Execute(new OperationDuplex<string>(_function.Object), "Red");

            _function.Verify((f)=>f.Execute("Red"), Times.Exactly(3));
        }
开发者ID:nelsestu,项目名称:objectflow,代码行数:7,代码来源:WhenRetryingFunctions.cs

示例9: DispatcherContext

 /// <summary>
 /// Initialies a new <see cref="DispatcherContext"/> synchronized with a new <see cref="Thread"/> instance
 /// </summary>
 /// <param name="threadApartmentState">The <see cref="ApartmentState"/> of the <see cref="Dispatcher"/>'s <see cref="Thread"/></param>
 ///<param name="owner">The <see cref="Dispatcher"/> that owns the <see cref="DispatcherContext"/></param>
 public DispatcherContext(Dispatcher owner, ApartmentState threadApartmentState)
 {
     Thread dispatcherThread;
     this.Owner = owner;
     dispatcherThread = new Thread(new ParameterizedThreadStart(this.ExecuteOperations));
     dispatcherThread.SetApartmentState(threadApartmentState);
 }
开发者ID:yonglehou,项目名称:Photon,代码行数:12,代码来源:DispatcherContext.cs

示例10: SoftRigidDynamicsWorld

		public SoftRigidDynamicsWorld(Dispatcher dispatcher, BroadphaseInterface pairCache,
			ConstraintSolver constraintSolver, CollisionConfiguration collisionConfiguration,
			SoftBodySolver softBodySolver)
            : base(IntPtr.Zero)
		{
            if (softBodySolver != null) {
                _softBodySolver = softBodySolver;
                _ownsSolver = false;
            } else {
                _softBodySolver = new DefaultSoftBodySolver();
                _ownsSolver = true;
            }

            _native = btSoftRigidDynamicsWorld_new2(dispatcher._native, pairCache._native,
                (constraintSolver != null) ? constraintSolver._native : IntPtr.Zero,
                collisionConfiguration._native, _softBodySolver._native);

            _collisionObjectArray = new AlignedCollisionObjectArray(btCollisionWorld_getCollisionObjectArray(_native), this);

            _broadphase = pairCache;
			_constraintSolver = constraintSolver;
			_dispatcher = dispatcher;
            _worldInfo = new SoftBodyWorldInfo(btSoftRigidDynamicsWorld_getWorldInfo(_native), true);
            _worldInfo.Dispatcher = dispatcher;
            _worldInfo.Broadphase = pairCache;
		}
开发者ID:rhynodegreat,项目名称:BulletSharpPInvoke,代码行数:26,代码来源:SoftRigidDynamicsWorld.cs

示例11: CharacterEditor

 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="viewModel"></param>
 public CharacterEditor(ViewModel viewModel, Dispatcher uiDispatcher, List<Unit> newRoster = null)
 {
     _uiDispatcher = uiDispatcher;
     DataContext = this;
     Test = "dhsfuifbvosfbo";
     WindowStyle = WindowStyle.ToolWindow;
     ViewModel = viewModel;
     //  Faction unit lists
     Factions = ViewModel.Factions;
     if (newRoster == null)
     {
         Factions[1].Units.Add(new Unit(1, BodyType.Enclave, WeaponType.SMG, Stance.Stand, 10, 10, 10, 10, 10, -1, -1, "James"));
         Factions[2].Units.Add(new Unit(2, BodyType.TribalFemale, WeaponType.Club, Stance.Stand, 10, 10, 10, 10, 10, -1, -1, "John"));
     }
     else
     {
         foreach (Unit u in newRoster)
         {
             Factions[u.OwnerID].Units.Add(u);
         }
     }
     InitializeComponent();
     body.ItemsSource = Enum.GetValues(typeof (BodyType));
     weapon.ItemsSource = Enum.GetValues(typeof (WeaponType));
     
 }
开发者ID:jo215,项目名称:Iso,代码行数:30,代码来源:CharacterEditor.xaml.cs

示例12: AndItShouldNotDoThat

        public void AndItShouldNotDoThat()
        {
            var handlerActivator = new HandlerActivatorForTesting();
            var pipelineInspector = new TrivialPipelineInspector();
            var handleDeferredMessage = new MockDeferredMessageHandler();
            var dispatcher = new Dispatcher(new InMemorySagaPersister(),
                                        handlerActivator,
                                        new InMemorySubscriptionStorage(),
                                        pipelineInspector,
                                        handleDeferredMessage,
                                        null);

            dispatcher.Dispatch(new TimeoutReply
            {
                CorrelationId = TimeoutReplyHandler.TimeoutReplySecretCorrelationId,
                CustomData = TimeoutReplyHandler.Serialize(new Message { Id = "1" })
            });

            dispatcher.Dispatch(new TimeoutReply
            {
                CustomData = TimeoutReplyHandler.Serialize(new Message { Id = "2" })
            });

            handleDeferredMessage.DispatchedMessages.Count.ShouldBe(1);
            var dispatchedMessage = handleDeferredMessage.DispatchedMessages[0];
            dispatchedMessage.ShouldBeOfType<Message>();
            ((Message)dispatchedMessage).Id.ShouldBe("1");
        }
开发者ID:nls75,项目名称:Rebus,代码行数:28,代码来源:DeferStealsOurTimeoutReplies.cs

示例13: AndItShouldNotDoThat

        public void AndItShouldNotDoThat()
        {
            var handlerActivator = new HandlerActivatorForTesting();
            var pipelineInspector = new TrivialPipelineInspector();
            var handleDeferredMessage = Mock<IHandleDeferredMessage>();
            var dispatcher = new Dispatcher(new InMemorySagaPersister(),
                                        handlerActivator,
                                        new InMemorySubscriptionStorage(),
                                        pipelineInspector,
                                        handleDeferredMessage);

            dispatcher.Dispatch(new TimeoutReply
            {
                CorrelationId = TimeoutReplyHandler.TimeoutReplySecretCorrelationId,
                CustomData = TimeoutReplyHandler.Serialize(new Message { Id = "1" })
            });

            dispatcher.Dispatch(new TimeoutReply
            {
                CustomData = TimeoutReplyHandler.Serialize(new Message { Id = "2" })
            });

            handleDeferredMessage.AssertWasCalled(x => x.Dispatch(Arg<Message>.Is.Anything), x => x.Repeat.Once());
            handleDeferredMessage.AssertWasCalled(x => x.Dispatch(Arg<Message>.Matches(y => y.Id == "1")));
        }
开发者ID:asgerhallas,项目名称:Rebus,代码行数:25,代码来源:DeferStealsOurTimeoutReplies.cs

示例14: initTTAPI

        /// <summary>
        /// Init and start TT API.
        /// </summary>
        /// <param name="instance">XTraderModeTTAPI instance</param>
        /// <param name="ex">Any exception generated from the XTraderModeDelegate</param>
        public void initTTAPI(XTraderModeTTAPI apiInstance, Exception ex)
        {
            m_dispatcher = Dispatcher.Current;
            m_session = apiInstance.Session;

            m_TTAPI = apiInstance;
            m_TTAPI.ConnectionStatusUpdate += ttapiInstance_ConnectionStatusUpdate;
            m_TTAPI.ConnectToXTrader();
        }
开发者ID:itsff,项目名称:CodeSamples_TTAPI_CSharp,代码行数:14,代码来源:AutospreaderManager.cs

示例15: Main

 private static void Main()
 {
     Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
     var database = new IssueTrackerDatabase();
     var issueTracker = new IssueTracker(database);
     var dispatcher = new Dispatcher(issueTracker);
     var engine = new Engine(dispatcher);
     engine.Run();
 }
开发者ID:EBojilova,项目名称:CSharpHQC,代码行数:9,代码来源:Program.cs


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