本文整理汇总了C#中IDispatcher.Foreground方法的典型用法代码示例。如果您正苦于以下问题:C# IDispatcher.Foreground方法的具体用法?C# IDispatcher.Foreground怎么用?C# IDispatcher.Foreground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDispatcher
的用法示例。
在下文中一共展示了IDispatcher.Foreground方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResolveOperationViewModel
public ResolveOperationViewModel(
string resolveOperationId,
IHistoricalItemStore<ResolveOperation> historicalItemStore,
IDispatcher dispatcher)
{
if (resolveOperationId == null) throw new ArgumentNullException("resolveOperationId");
if (historicalItemStore == null) throw new ArgumentNullException("historicalItemStore");
dispatcher.Background(() =>
{
ResolveOperation resolveOperation;
if (historicalItemStore.TryGetItem(resolveOperationId, out resolveOperation))
{
var subOperations = Traverse.PreOrder(resolveOperation, r => r.SubOperations)
.Select(o => new SubResolveOperationViewModel(o))
.ToList();
dispatcher.Foreground(() =>
{
foreach (var subResolveOperationViewModel in subOperations)
_subOperations.Add(subResolveOperationViewModel);
});
}
});
}
示例2: ComponentDetailViewModel
public ComponentDetailViewModel(string componentId, IDispatcher dispatcher, IActiveItemRepository<Component> components)
{
dispatcher.Background(() =>
{
Component component;
if (!components.TryGetItem(componentId, out component))
throw new ArgumentException("Unknown component.");
var description = component.Description;
var services = component.DescribeServices();
var metadata = component.Metadata;
var sharing = component.Sharing;
var lifetime = component.Lifetime;
var activator = component.Activator;
var ownership = component.Ownership;
var target = component.TargetComponentId;
var id = component.Id;
dispatcher.Foreground(() =>
{
Description = description;
Metadata = metadata;
Services = services;
Sharing = sharing.ToString();
Lifetime = lifetime.ToString();
Activator = activator.ToString();
Ownership = ownership.ToString();
Target = target;
Id = id;
});
});
}