本文整理汇总了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;
}
示例2: Given
public void Given()
{
_operation = new FailOnceOperation();
_invoker = new OperationInvoker<string>(_operation);
_invoker.Policies.Add(new Retry(null));
_engine = new Dispatcher<string>();
}
示例3: LightClawSynchronizationContext
public LightClawSynchronizationContext(Dispatcher dispatcher, DispatcherPriority priority)
{
Contract.Requires<ArgumentNullException>(dispatcher != null);
this.dispatcher = dispatcher;
this.priority = priority;
}
示例4: FinalizeWorkDispatcher
private static void FinalizeWorkDispatcher(Dispatcher dispatcher)
{
if (dispatcher != null)
{
dispatcher.Dispose();
}
}
示例5: Dispatcher
public Dispatcher()
{
Debug.Assert(_instance == null);
_instance = this;
_thread = new Thread(run);
_thread.Start();
}
示例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\\");
}
示例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;
}
}
示例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));
}
示例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);
}
示例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;
}
示例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));
}
示例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");
}
示例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")));
}
示例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();
}
示例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();
}