示例#1
0
        void Dispose(bool disposing)
        {
            if (Lock != null)
            {
                if (disposing)
                {
                    ClearAllLevels();
                }

                Levels.Clear();
                Levels = null;

                tmp.Clear();
                tmp = null;

                Lock.Dispose();
                Lock = null;
            }
        }
示例#2
0
        void Dispose(bool disposing)
        {
            if (IsStarted)
            {
                if (invalidator != null)
                {
                    invalidator.CancelAsync();
                    invalidator.DoWork -= new DoWorkEventHandler(invalidatorWatch);
                    invalidator.Dispose();
                    invalidator = null;
                }

                if (Refresh != null)
                {
                    Refresh.Set();
                    Refresh.Close();
                    Refresh = null;
                }

                int x = Interlocked.Decrement(ref instances);
                Debug.WriteLine("OnMapClose: " + x);

                CancelAsyncTasks();
                IsStarted = false;

                if (Matrix != null)
                {
                    Matrix.Dispose();
                    Matrix = null;
                }

                if (FailedLoads != null)
                {
                    lock (FailedLoads)
                    {
                        FailedLoads.Clear();
                        RaiseEmptyTileError = false;
                    }
                    FailedLoads = null;
                }

                // cancel waiting loaders
                Monitor.Enter(tileLoadQueue);
                try
                {
                    Monitor.PulseAll(tileLoadQueue);
                    tileDrawingList.Clear();
                }
                finally
                {
                    Monitor.Exit(tileLoadQueue);
                }

                if (tileDrawingListLock != null)
                {
                    tileDrawingListLock.Dispose();
                    tileDrawingListLock = null;
                    tileDrawingList     = null;
                }

                if (x == 0)
                {
                    if (disposing)
                    {
                        GMaps.Instance.MemoryCache.Clear();
                    }
                }
            }
        }