Why falling error?

There's a client code:
private void btChangeState_Click(object sender, RoutedEventArgs e)
{
 if (!IsConnected)
{
 Exception error = null;

 if (!TryConnect($"net.tcp://{tbIP.Text}:{tbPort.Text}/JobService", out, Proxy, out error))
{
 MessageBox.Show ("error".Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
}
else
{
Proxy.Close();
}

 IsConnected = !IsConnected;
Jobs.Clear();
}

private bool TryConnect(endpoint string, out JobServiceClient proxy, out Exception error)
{
try
{
 var callback = new the clientcallback();
 callback.GiveJob += Callback_GiveJobAsync;
 var ctx = new InstanceContext(callback);
 proxy = new JobServiceClient(ctx);
 proxy.Endpoint.Address = new EndpointAddress(endpoint);
proxy.Connect();
 error = null;
 return true;
}
 catch (Exception e)
{
 proxy = null;
 error = e;
 return false;
}
}

Why the call to Connect I have this error falls? "This type of CollectionView does not support changes to its SourceCollection from a thread different from the Dispatcher thread." No additional threads in this case are not used, all basically.

Now sure to not debug the client where the error POPs up and the server actually calls the function Connect via a proxy. Campaign error there. But why is it popping up I still don't understand... In the contract of service has collection:
public ObservableCollection<clientview> Clients { get; } = new ObservableCollection<clientview>();</clientview></clientview>
In the Connect function just creates a ClientView object and adds it to her. And that's when this add (according to the debugger) crashes bug, which is simply passed to the client. But everything happens in a single thread, no more threads than there! Where is the mistake?

P. S. Dispatcher.Invoke does not help.
July 12th 19 at 21:06
2 answers
July 12th 19 at 21:08
Solution
As it turned out empirically the problem was that the button triggers the server to have an asynchronous handler. It is not entirely clear how, but he influenced it, because the cost to make it synchronous, as the error disappeared.
July 12th 19 at 21:10
No additional threads in this case are not used, all basically.


That's what You think.
WCF hides under a lot of logic that can work the threads other than the main one.
The error You got clearly indicates that the addition to the collection is not in the UI thread.
To fix it I had to call Invoke from Dispatcher'and applications, and via Application.Current.Dispatcher.Invoke. And Dispatcher.Current can be quite different, depends on the synchronization context.
I already wrote that this method does not help. You read to the end? Is not. I'm leaving the event-driven model in MVVM. - layla commented on July 12th 19 at 21:13
Of course I read to the end, very often here, questions emerge when the author does not understand what to do and can confuse the Respondent audience, this is the first.
Second, there is a big difference between Application.Current.Dispatcher.Invoke and Dispatcher.CurrentDispatcher.Invoke, from Your question it is not entirely clear whether You used WPF, come,
And thirdly, just yesterday, I realized, what's the problem: since the handler was async, the collection was created in a thread other than the main, therefore, the modification of the collection from the main thread and created a bug - adelle commented on July 12th 19 at 21:16

Find more questions by tags C#WCFWPF