我在wpf程序中copy了一段多线程的代码
/// <summary>
/// Inserts an element into the List at the specified index.
/// </summary>
/// <param name="index">The zero-based index at which item should be inserted.</param>
/// <param name="item">The object to insert. The value can be null for reference types.</param>
public void Insert(int index, T item)
{
this._list.Insert(index, item);
this._dispatcher.BeginInvoke(DispatcherPriority.Send,
new InsertItemCallback(InsertItemFromDispatcherThread),
index,
new object[] { item }
);
}
运行和使用没有问题,
但是当我将这段代码copy到silverlight程序中使用时,编译报错,
Error 4 'System.Windows.Threading.DispatcherPriority' is inaccessible due to its protection level
原因是因为 DispatcherPriority 是一个 internal 的 param.
请问,silverlight 中是否有等效于DispatcherPriority.Send 的什么可以使用?
附:
private Dispatcher _dispatcher;
this._dispatcher.BeginInvoke 需要的参数:
this._dispatcher.BeginInvoke(DispatcherPriority priority, Delegate method, object arg, params object[] args);