AddSafe方法是否真的線程安全或我所做的是錯誤的?我的收藏線程安全嗎?
public static MyCollection myCol = new MyCollection();
class MyCollection: ObservableCollection<string>
{
public void AddSafe(string item)
{
lock(this)
{
this.Add(item);
}
}
}
http://stackoverflow.com/questions/23108045/how-to-make-observablecollection-thread-safe檢查此! – TripleEEE
從鏈接檢查羅伯特弗雷澤的答案! – mybirthname