[C#]Cross thread operation on control without InvokeRequired
Been playing with this for a while now...
I have a form with a custom mapping control object (GMap.NET).
Object has to be initiated first, then map provider (google, bing, openstreet, etc) has to be set. When that is set, it is being loaded/initialized which takes 5-10 seconds.
I wan't it to load asynchronously, which kinda works. Kinda...
Here is form constructor: [C#] public Dashboard() { InitializeComponent(); - Pastebin.com
With async:
Form loads right away and map provider is being loaded aside.
Without async:
Form doesn't show up until map provider is loaded.
So it's kinda nice to load map provider async instead of 10 seconds lag before form shows up. But once form is up and map provider is loading, sometimes code/debugger throws cross thread error. Sometimes it happens sometimes it doesn't. Also sometimes it happens when map provider is loaded...
MapControl doens't have .InvokeRequired unlike other form element so I have no idea what to do.
Also MapProvider is this
Code:
MapControl.MapProvider = GMapProviders.GoogleMap;
Any ideas?
Re: [C#]Cross thread operation on control without InvokeRequired
Can I see the error?
.NET doesn't allow separate threads to access forms (GUI).
Try looking into this:
Synchronizing calls to the UI in a multi-threaded application | Gabriel Schenker's Blog