Current thread is not a GUI
Atom
10.02.2012


Коллеги, подскажите, куда копать? Несколько дней разбираюсь

Наткнулся на ошибку "Current thread is not a GUI"

По стеку вот что выполняется:

при попытке выполнить
myVar=new myClass


вываливается на строке
myClass
Property MyProp As New ThreadSafeObservableCollection(Of myAnotherClass)
[skip]
end Class

Теги:


Спасибо:


vfreeman

Фотография
Дата: 10.02.2012
Ответить


Продолжаю копать - в другом месте Visual Stidio - отлавливает Exeption, но
не показывает в каком месте - я примерно понимаю где - при попытке добавить в коллекцию элемент

PropName.Add(e.PropertyName)

я таким образом пытаюсь вызвать событие PropertyChanged в ГУЕ-вом потоке
может я что-то не так делаю? а может ThreadSafeObservableCollection не совсем ThreadSafe? [cursing]

Код
Private PropName As New ThreadSafeObservableCollection(Of String)

Private Sub myGuiSync()
        For Each itm In PropName
            NotifyPropertyChanged(itm)
        Next
        PropName.Clear()
End Sub

Private Sub Strategy_PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Handles Strategy.PropertyChanged
NotifyPropertyChanged(e.PropertyName))
        PropName.Add(e.PropertyName)
        GuiSync(Application.Current, AddressOf myGuiSync)
End Sub


а вот сам стек

Код
в System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
       в System.Collections.Generic.List`1.Insert(Int32 index, T item)
       в System.Collections.ObjectModel.Collection`1.InsertItem(Int32 index, T item)
       в System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
       в Ecng.Xaml.ThreadSafeObservableCollection`1.InsertItem(Int32 index, T item)
       в Ecng.Xaml.ThreadSafeObservableCollection`1.<>c__DisplayClass2.<InsertItem>b__0()
       в System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       в MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       в System.Windows.Threading.DispatcherOperation.InvokeImpl()
       в System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
       в System.Threading.ExecutionContext.runTryCode(Object userData)
       в System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       в System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       в System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       в System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       в System.Windows.Threading.DispatcherOperation.Invoke()
       в System.Windows.Threading.Dispatcher.ProcessQueue()
       в System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       в MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       в MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       в System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       в MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       в System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       в MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       в MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       в System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       в System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       в System.Windows.Threading.Dispatcher.Run()
       в System.Windows.Application.RunDispatcher(Object ignore)
       в System.Windows.Application.RunInternal(Window window)
       в System.Windows.Application.Run(Window window)
       в System.Windows.Application.Run()
       в StrategyManager.Application.Main() в C:\work\vb\StrategyManager\obj\x86\Debug\Application.g.vb:строка 65
       в System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       в System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       в Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       в System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       в System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       в System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       в System.Threading.ThreadHelper.ThreadStart()


Спасибо:


Добавить файлы через драг-н-дроп, , или вставить из буфера обмена.

loading
clippy