/// <summary> /// 主线程做事 /// </summary> /// <param name="action">要做的内容</param> /// <param name="synchronization">是否同步执行</param> private void Dosomething(Action action, bool synchronization) { if (mapControl == null) { return; } if (synchronization) { if (mapControl.InvokeRequired) { mapControl.Invoke(action); } else { action(); } } else { if (mapControl.InvokeRequired) { mapControl.BeginInvoke(action); } else { action(); } } }
private void refreshTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { lock (lockObj) { isRefreshCall = true; refreshTimer.Stop(); } // 单位时间内,只执行一次,且是在单位时间结束时执行 if (axGlobeControl.InvokeRequired) { axGlobeControl.Invoke((Action) delegate() { axGlobeControl.GlobeDisplay.RefreshViewers(); }); } else { //(axGlobeControl.GlobeDisplay as IGlobeDisplayLayers2).RefreshLayer(refreshLayer); axGlobeControl.GlobeDisplay.RefreshViewers(); } }