/// <summary> /// Creates a new T3 COM object /// </summary> /// <param name="AppName">The name of your application</param> /// <param name="CreateNewProcess">If true, will start a new instance of T3. If false will try to connect /// to an existing T3 process.</param> public T3Lib(string AppName, bool CreateNewProcess) { if (!CreateNewProcess) { try { SDK = (IT3SDK)System.Runtime.InteropServices.Marshal.GetActiveObject("T3.T3SDK"); } catch { SDK = new T3SDKClass(); //creates connection to T3 COM object } } else { SDK = new T3SDKClass(); } SDKClient = new T3SDKClient(AppName); // create new SDKClient (allows event handling) SidebarHTMLClient = new T3SDKSidebarHTMLClient(); Layer = SDK.GetLayerManager(); //get a map layer object from the sdk pAppInteractor = Layer.GetAppInteractor(); pMapInteractor = Layer.GetMapInteractor(); SDK.SetClient(Layer,SDKClient); //setup the sdkclient for handling the current map layer SDK.SetSidebarHTMLClient (Layer,SidebarHTMLClient); //setup html sidebar for event handling SDKClient.DisconnectRequest += Dispose; }
/// <summary> /// Release resources for COM object (otherwise we get weird errors from T3) /// This MUST be called before being GC'd /// </summary> public void Dispose() { try { Layer.ClearLayers(); //clear the layer in TUMONZ SDK.ReleaseLayerManager(Layer); //Release layer resources SDKClient = null; SidebarHTMLClient = null; Layer = null; SDK = null; GC.Collect(); } catch { //if tumonz has already been closed, we will get an error here } }