Message 1 of 9
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to close a drawing, but when I do I receive an error:
System.NotSupportedException: 'This type of CollectionView does not support changes to its SourceCollection from a thread different from the Dispatcher thread.'
public void CloseDWG()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor editor = doc.Editor;
if (editor.IsQuiescent)
{
doc.CloseAndDiscard(); // <- error here
}
}
I suppose I need to move the code to the calling thread, I have gotten this far but it doesn't compile.
Application.Invoke(() =>
{
Document doc = Application.DocumentManager.MdiActiveDocument;
if (doc != null)
{
Editor editor = doc.Editor;
if (editor.IsQuiescent)
{
busyCheckTimer.Stop();
// The drawing is no longer busy, take action here
doc.CloseAndDiscard();
}
}
});
Any help would be appreciated. 🙂
Solved! Go to Solution.