﻿<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type='text/css' href='https://stocksharp.ru/css/style.css'?>
<?xml-stylesheet type='text/css' href='https://stocksharp.ru/css/bbeditor.css'?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title type="html">Current thread is not a GUI</title>
  <id>~/topic/2390/current-thread-is-not-a-gui/</id>
  <rights type="text">Copyright @ StockSharp Platform LLC 2010 - 2025</rights>
  <updated>2026-04-07T03:50:40Z</updated>
  <logo>https://stocksharp.ru/images/logo.png</logo>
  <link href="https://stocksharp.ru/handlers/atom.ashx?category=topic&amp;id=2390" rel="self" type="application/rss+xml" />
  <entry>
    <id>https://stocksharp.ru/posts/m/16293/</id>
    <title type="text">Продолжаю копать - в другом месте Visual Stidio - отлавливает Exeption, но не показывает в каком мес...</title>
    <published>2012-02-10T09:11:52Z</published>
    <updated>2012-02-10T09:11:52Z</updated>
    <author>
      <name>vfreeman</name>
      <uri>https://stocksharp.ru/users/773/</uri>
      <email>info@stocksharp.ru</email>
    </author>
    <content type="html">Продолжаю копать - в другом месте Visual Stidio - отлавливает Exeption, но &lt;br /&gt;не показывает в каком месте - я примерно понимаю где - при попытке добавить в коллекцию элемент&lt;br /&gt;&lt;br /&gt;&lt;b&gt;PropName.Add(e.PropertyName)&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;я таким образом пытаюсь вызвать событие PropertyChanged в ГУЕ-вом потоке&lt;br /&gt;может я что-то не так делаю? а может ThreadSafeObservableCollection не совсем &lt;b&gt;ThreadSafe&lt;/b&gt;? [cursing] &lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;strong&gt;Код&lt;/strong&gt;&lt;div class="innercode"&gt;&lt;pre class="brush:vb"&gt;
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
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;а вот сам стек&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;strong&gt;Код&lt;/strong&gt;&lt;div class="innercode"&gt;&lt;pre class="brush:plain"&gt;
в 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.&amp;lt;&amp;gt;c__DisplayClass2.&amp;lt;InsertItem&amp;gt;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&amp;amp; handled)
       в MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean&amp;amp; 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&amp;amp; 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()&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;</content>
    <rights type="html">Copyright @ StockSharp Platform LLC 2010 - 2025</rights>
  </entry>
  <entry>
    <id>https://stocksharp.ru/posts/m/16286/</id>
    <title type="text">Коллеги, подскажите, куда копать? Несколько дней разбираюсь Наткнулся на ошибку &amp;quot;Current thread is n...</title>
    <published>2012-02-10T07:05:39Z</published>
    <updated>2012-02-10T07:05:39Z</updated>
    <author>
      <name>vfreeman</name>
      <uri>https://stocksharp.ru/users/773/</uri>
      <email>info@stocksharp.ru</email>
    </author>
    <content type="html">Коллеги, подскажите, куда копать? Несколько дней разбираюсь&lt;br /&gt;&lt;br /&gt;Наткнулся на ошибку &amp;quot;Current thread is not a GUI&amp;quot;&lt;br /&gt;&lt;br /&gt;По стеку вот что выполняется:&lt;br /&gt;&lt;br /&gt;при попытке выполнить&lt;br /&gt;myVar=new myClass&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;вываливается на строке&lt;br /&gt;myClass&lt;br /&gt;&lt;em&gt;Property MyProp As New ThreadSafeObservableCollection(Of myAnotherClass)&lt;/em&gt;&lt;br /&gt;[skip]&lt;br /&gt;end Class&lt;br /&gt;</content>
    <rights type="html">Copyright @ StockSharp Platform LLC 2010 - 2025</rights>
  </entry>
</feed>