對不起,我還是不明白,UI是如何工作的,什麼是Dispatcher
調度WCF模型 - 添加方法
我有這樣DispatchingWcfModel
:
public interface IWcfModel
{
List<ConsoleData> DataList { get; set; }
event Action<List<ConsoleData>> DataArrived;
}
class DispatchingWcfModel : IWcfModel
{
private readonly IWcfModel _underlying;
private readonly Dispatcher _currentDispatcher;
public DispatchingWcfModel(IWcfModel model)
{
_currentDispatcher = Dispatcher.CurrentDispatcher;
_underlying = model;
_underlying.DataArrived += _underlying_DataArrived;
}
private void _underlying_DataArrived(List<ConsoleData> obj)
{
Action dispatchAction =() =>
{
if (DataArrived != null)
{
DataArrived(obj);
}
};
_currentDispatcher.BeginInvoke(DispatcherPriority.DataBind, dispatchAction);
}
public List<ConsoleData> DataList
{
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
public event Action<List<ConsoleData>> DataArrived;
}
現在我想補充int[] ConnectionStats { get; set; }
。我應該爲它引入單獨的事件嗎?我應該在DispatchingWcfModel中編寫什麼?我想有接口這樣的:
public interface IWcfModel
{
List<ConsoleData> DataList { get; set; }
int[] ConnectionStats { get; set; }
event Action<List<ConsoleData>> DataArrived;
}
如果你不明白你在做什麼,你爲什麼要修改它? – x0n
我希望我能夠理解使用這些例子:) – javapowered
你讀過[參考](http://msdn.microsoft.com/en-us/library/ms741870.aspx)? –