Inheritance: System.Runtime.ConstrainedExecution.CriticalFinalizerObject
コード例 #1
1
ファイル: Program.cs プロジェクト: alienwaredream/toolsdotnet
        private static void LockOnReaderWriterLock()
        {
            Console.WriteLine("About to lock on the ReaderWriterLock. Debug after seeing \"Signaled to acquire the reader lock.\"");
            ReaderWriterLock rwLock = new ReaderWriterLock();

            ManualResetEvent rEvent = new ManualResetEvent(false);
            ManualResetEvent pEvent = new ManualResetEvent(false);

            ThreadPool.QueueUserWorkItem((object state) =>
            {
                rwLock.AcquireWriterLock(-1);
                Console.WriteLine("Writer lock acquired!");
                rEvent.Set();
                pEvent.WaitOne();
            });

            rEvent.WaitOne();

            Console.WriteLine("Signaled to acquire the reader lock.");

            rwLock.AcquireReaderLock(-1);

            Console.WriteLine("Reader lock acquired");

            pEvent.Set();

            Console.WriteLine("About to end the program. Press any key to exit.");
            Console.ReadKey();
        }
コード例 #2
0
ファイル: ExpansionStore.cs プロジェクト: anxkha/DRM
        public ExpansionStore()
        {
            _loaded = false;
            _cache = null;

            _lock = new ReaderWriterLock();
        }
コード例 #3
0
        /// <summary>
        /// Initializes the StrengthenMgr.
        /// </summary>
        /// <returns></returns>
        public static bool Init()
        {
            try
            {
                m_lock = new System.Threading.ReaderWriterLock();

                _ally = new Dictionary <string, int>();
                if (!Load(_ally))
                {
                    return(false);
                }

                _consortia = new Dictionary <int, ConsortiaInfo>();
                if (!LoadConsortia(_consortia))
                {
                    return(false);
                }

                return(true);
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("ConsortiaMgr", e);
                }
                return(false);
            }
        }
コード例 #4
0
ファイル: InstrumentedAssembly.cs プロジェクト: nickchal/pash
		static InstrumentedAssembly()
		{
			InstrumentedAssembly.readerWriterLock = new ReaderWriterLock();
			InstrumentedAssembly.mapIDToPublishedObject = new Hashtable();
			InstrumentedAssembly.mapPublishedObjectToID = new Hashtable();
			InstrumentedAssembly.upcountId = 0xeff;
		}
コード例 #5
0
ファイル: ExperienceRateMgr.cs プロジェクト: uvbs/DDTank-3.0
        public static bool Init()
        {
            try
            {
                //_RateInfo = new ExperienceRateInfo();
                //_RateInfo.Rate = 1;
                m_lock = new System.Threading.ReaderWriterLock();

                using (ServiceBussiness db = new ServiceBussiness())
                {
                    _RateInfo = db.GetExperienceRate(WorldMgr.ServerID);
                }

                if (_RateInfo == null)
                {
                    _RateInfo      = new ExperienceRateInfo();
                    _RateInfo.Rate = -1;
                }

                return(true);
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("ExperienceRateMgr", e);
                }
                return(false);
            }
        }
コード例 #6
0
ファイル: UpBuffer.cs プロジェクト: lexzh/Myproject
 public UpBuffer(string string_0)
 {
     this.list_0 = new List<int>(30);
     this.readerWriterLock_0 = new ReaderWriterLock();
     this.hashtable_0 = Hashtable.Synchronized(new Hashtable(0xa3));
     this.AlarmCodeList = string_0;
 }
コード例 #7
0
    // Use this for initialization
    void Start()
    {
        System.Net.Sockets.TcpClient sock = new System.Net.Sockets.TcpClient();
        sock.Connect(address, port);
        if (!sock.Connected)
        {
            Debug.Log("Twitch contact failed");
            return;
        }
        eventQueue  = new Queue <Queue <string> >();
        outputQueue = new Queue <string>();
        inLock      = new System.Threading.ReaderWriterLock();
        outLock     = new System.Threading.ReaderWriterLock();
        netStream   = sock.GetStream();
        read        = new System.IO.StreamReader(netStream);
        write       = new System.IO.StreamWriter(netStream);

        write.WriteLine("PASS " + oath);
        write.WriteLine("NICK " + username);
        write.Flush();

        messages = new Queue <string>();

        procIn = new System.Threading.Thread(() => IRCInputProcedure());
        procIn.Start();
        procOut = new System.Threading.Thread(() => IRCOutputProcedure());
        procOut.Start();

        Debug.Log("We're in");
    }
コード例 #8
0
ファイル: CharacterStore.cs プロジェクト: anxkha/DRM
        public CharacterStore()
        {
            _loaded = false;
            _cache = new List<Character>();

            _lock = new ReaderWriterLock();
        }
コード例 #9
0
ファイル: RoleStore.cs プロジェクト: anxkha/DRM
        public RoleStore()
        {
            _loaded = false;
            _cache = new List<Role>();

            _lock = new ReaderWriterLock();
        }
コード例 #10
0
ファイル: SpecializationStore.cs プロジェクト: anxkha/DRM
        public SpecializationStore()
        {
            _loaded = false;
            _cache = new List<Specialization>();;

            _lock = new ReaderWriterLock();
        }
コード例 #11
0
ファイル: CacheProvider.cs プロジェクト: npenin/uss
		public override void InitializeConfiguration()
		{
            _Entities = new IdentityMap();
            _Scalars = new Dictionary<string,object>();
            _Loads = new Hashtable();
            _RWL = new ReaderWriterLock();
		}
コード例 #12
0
ファイル: RaceClassesStore.cs プロジェクト: anxkha/DRM
        public RaceClassesStore()
        {
            _loaded = false;
            _cache = null;

            _lock = new ReaderWriterLock();
        }
コード例 #13
0
ファイル: Scheduler.cs プロジェクト: SolidSnake74/SharpCore
 /// <summary>
 /// Executes a job on demand, rather than waiting for its regularly scheduled time.
 /// </summary>
 /// <param name="job">The job to be executed.</param>
 public static void ExecuteJob(JobBase job)
 {
     ReaderWriterLock rwLock = new ReaderWriterLock();
     try
     {
         rwLock.AcquireReaderLock(Timeout.Infinite);
         if (job.Executing == false)
         {
             LockCookie lockCookie = rwLock.UpgradeToWriterLock(Timeout.Infinite);
             try
             {
                 if (job.Executing == false)
                 {
                     job.Executing = true;
                     QueueJob(job);
                 }
             }
             finally
             {
                 rwLock.DowngradeFromWriterLock(ref lockCookie);
             }
         }
     }
     finally
     {
         rwLock.ReleaseReaderLock();
     }
 }
コード例 #14
0
    // Use this for initialization
    void Start()
    {
        inst   = this;
        server = new System.Net.Sockets.TcpClient();
        server.Connect(address, port);
        if (!server.Connected)
        {
            Debug.Log("Failed to connect!");
            return;
        }
        Debug.Log("Connected");
        inputQueue  = new Queue <string>();
        outputQueue = new Queue <string>();
        netStream   = server.GetStream();
        read        = new System.IO.StreamReader(netStream);
        write       = new System.IO.StreamWriter(netStream);
        outlock     = new System.Threading.ReaderWriterLock();
        inlock      = new System.Threading.ReaderWriterLock();

        write.WriteLine("PASS " + oath);
        write.WriteLine("NICK " + username.ToLower());

        write.Flush();

        procIn = new System.Threading.Thread(() => IRCInputProcedure());
        procIn.Start();
        procOut = new System.Threading.Thread(() => IRCOutputProcedure());
        procOut.Start();

        Debug.Log("We're in");
    }
コード例 #15
0
        public static string getOneCell()
        {
            string encodedOrder=null;
             readSem.WaitOne();// wait until buffer cell is not empty then only read
            ReaderWriterLock rw=new ReaderWriterLock();
            rw.AcquireWriterLock(Timeout.Infinite);
            try{
            //reading from buffer --- ciruclar queue

            if (front_read == bufferSize - 1)
                 front_read = 0;
            else
                 {

                     front_read = front_read + 1;
                  }
               encodedOrder = buffer[front_read];
               buffer[front_read] = string.Empty;
               String[] arr=encodedOrder.Split('#');
               Console.WriteLine("  chicken farm got an order from {0} of {1} chicken",arr[0],arr[2]);
            }
            catch (Exception e){ Console.WriteLine(""); }
            finally
            {
            rw.ReleaseWriterLock();
            writeSem.Release();

            }

            return encodedOrder;
        }
コード例 #16
0
        public static bool Init()
        {
            try
            {
                //_RateInfo = new ExperienceRateInfo();
                //_RateInfo.Rate = 1;
                m_lock = new System.Threading.ReaderWriterLock();

                using (ServiceBussiness db = new ServiceBussiness())
                {
                    _RateInfo = db.GetExperienceRate(WorldMgr.ServerID);
                }

                if (_RateInfo == null)
                {
                    _RateInfo = new ExperienceRateInfo();
                    _RateInfo.Rate = -1;
                }

                return true;
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                    log.Error("ExperienceRateMgr", e);
                return false;
            }

        }
コード例 #17
0
ファイル: ReaderLock.cs プロジェクト: anxkha/DRM
        public ReaderLock(ReaderWriterLock rwLock)
        {
            if (null == rwLock) throw new Exception("Don't pass a null ReaderWriterLock object!");

            _lock = rwLock;
            _lock.AcquireReaderLock(Timeout.Infinite);
        }
コード例 #18
0
 private DatabaseResource(string path)
 {
     Path = path;
     _refCount = 1;
     SessionFactory = SessionFactoryFactory.CreateSessionFactory(path, ProteomeDb.TYPE_DB, false);
     DatabaseLock = new ReaderWriterLock();
 }
コード例 #19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DisposableLockGrabber"/> class.
        /// </summary>
        /// <param name="rwlock">The rwlock.</param>
        /// <param name="type">The type.</param>
        /// <param name="timeoutMilliseconds">The timeout milliseconds.</param>
        public DisposableLockGrabber(ReaderWriterLock rwlock, ReaderWriterLockSynchronizeType type, int timeoutMilliseconds)
        {
            m_rwlock = rwlock;
            m_type = type;

            DoLock(timeoutMilliseconds);
        }
コード例 #20
0
ファイル: BlibDb.cs プロジェクト: lgatto/proteowizard
 private BlibDb(String path)
 {
     FilePath = path;
     SessionFactory = BlibSessionFactoryFactory.CreateSessionFactory(path, false);
     DatabaseLock = new ReaderWriterLock();
     _progressStatus = new ProgressStatus(string.Empty);
 }
コード例 #21
0
ファイル: SyntaxCatalog.cs プロジェクト: svermeulen/iris
 static SyntaxCatalog()
 {
     m_timeoutForSyntaxesLock = TimeSpan.FromSeconds(10);
     m_syntaxesLock = new ReaderWriterLock();
     m_syntaxesByIdOrAlias = new SortedDictionary<string, Syntax>(StringComparer.OrdinalIgnoreCase);
     m_lockForCatalogLoad = new object();
 }
コード例 #22
0
ファイル: MapMgr.cs プロジェクト: uvbs/DDTank-3.0
        public static bool Init()
        {
            try
            {
                random = new ThreadSafeRandom();
                m_lock = new System.Threading.ReaderWriterLock();

                _maps     = new Dictionary <int, MapPoint>();
                _mapInfos = new Dictionary <int, Map>();
                if (!LoadMap(_maps, _mapInfos))
                {
                    return(false);
                }

                _serverMap = new Dictionary <int, List <int> >();
                if (!InitServerMap(_serverMap))
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("MapMgr", e);
                }
                return(false);
            }
            return(true);
        }
コード例 #23
0
ファイル: Log.cs プロジェクト: kangwl/KANG.Frame
 /// <summary>
 ///     创建日志文件
 /// </summary>
 private void CreatLog() {
     TextWriter logwrite = null;
     var writelock = new ReaderWriterLock();
     try {
         writelock.AcquireWriterLock(-1);
         var directoryInfo = m_fileinfo.Directory;
         if (directoryInfo != null && !directoryInfo.Exists) {
             var directory = m_fileinfo.Directory;
             if (directory != null) directory.Create();
         }
         logwrite = TextWriter.Synchronized(m_fileinfo.CreateText());
         logwrite.WriteLine("#------------------------------------------------------");
         logwrite.WriteLine("#     SYSTEM LOG                                  ");
         logwrite.WriteLine("#                                                      ");
         logwrite.WriteLine("#     Create at " + DateTime.Now.ToString(CultureInfo.InvariantCulture) + "   ");
         logwrite.WriteLine("#                                                      ");
         logwrite.WriteLine("#------------------------------------------------------");
         logwrite.Close();
     }
     catch (Exception ex) {
         throw new Exception("创建系统日志文件出错!" + ex);
     }
     finally {
         writelock.ReleaseWriterLock();
         if (logwrite != null) {
             logwrite.Close();
         }
     }
 }
コード例 #24
0
		internal HttpApplicationState ()
		{
			// do not use the public (empty) ctor as it required UnmanagedCode permission
			_AppObjects = new HttpStaticObjectsCollection (this);
			_SessionObjects = new HttpStaticObjectsCollection (this);
			_Lock = new ReaderWriterLock ();
		}
コード例 #25
0
ファイル: RaidInstanceStore.cs プロジェクト: anxkha/DRM
        public RaidInstanceStore()
        {
            _loaded = false;
            _cache = new List<RaidInstance>();

            _lock = new ReaderWriterLock();
        }
コード例 #26
0
		public Cache () {
			_nItems = 0;

			_lockEntries = new ReaderWriterLock ();
			_arrEntries = new Hashtable ();

			_objExpires = new CacheExpires (this);
		}
コード例 #27
0
ファイル: Scene.cs プロジェクト: geniushuai/DDTank-3.0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="info"></param>
 public Scene(ServerInfo info)
 {
     _info = info;
     _info.Online = 0;
     _info.State = 2;
     _players = new Dictionary<int, GamePlayer>();
     _locker = new ReaderWriterLock();
 }
コード例 #28
0
ファイル: EventSource.cs プロジェクト: nickchal/pash
		static EventSource()
		{
			EventSource.eventSources = new ArrayList();
			EventSource.shutdownInProgress = 0;
			EventSource.preventShutdownLock = new ReaderWriterLock();
			AppDomain.CurrentDomain.ProcessExit += new EventHandler(EventSource.ProcessExit);
			AppDomain.CurrentDomain.DomainUnload += new EventHandler(EventSource.ProcessExit);
		}
コード例 #29
0
        public ReaderWriterObjectLocker()
        {
            // TODO: update to ReaderWriterLockSlim on .net 3.5
            locker = new ReaderWriterLock();

            writerReleaser = new WriterReleaser(this);
            readerReleaser = new ReaderReleaser(this);
        }
コード例 #30
0
 public void Dispose()
 {
     if (m_l != null)
     {
         m_l.ReleaseWriterLock();
         m_l = null;
     }
 }
コード例 #31
0
ファイル: ObjectSecurity.cs プロジェクト: nicolas-raoul/mono
		internal ObjectSecurity (CommonSecurityDescriptor securityDescriptor)
		{
			if (securityDescriptor == null)
				throw new ArgumentNullException ("securityDescriptor");
				
			descriptor = securityDescriptor;
			rw_lock = new ReaderWriterLock ();
		}
コード例 #32
0
ファイル: ReaderWriterLockTest.cs プロジェクト: nlhepler/mono
		public void TestIsWriterLockHeld ()
		{
			rwlock = new ReaderWriterLock ();
			Assert.IsTrue (!rwlock.IsWriterLockHeld, "#1");
			rwlock.AcquireWriterLock (500);
			Assert.IsTrue (rwlock.IsWriterLockHeld, "#2");
			RunThread (new ThreadStart (IsWriterLockHeld_2));
			rwlock.ReleaseWriterLock ();
		}
コード例 #33
0
 /// <summary>
 /// .ctor
 /// </summary>
 /// <param name="alock">Lock to handle</param>
 /// <param name="timeout">timeout to acquire lock</param>
 /// <param name="mode">Lock mode</param>
 public DisposableReaderWriterLock(ReaderWriterLock alock, TimeSpan timeout, LockMode mode = LockMode.Read)
 {
     ParametersValidator.IsNotNull(alock, ()=>alock);
     _lock = alock;
     _timeout = timeout;
     _mode = mode;
     AcquireLock();
     Logger.TraceFormat("lock created timeout={0}, mode ={1}", timeout, mode);
 }
コード例 #34
0
 static SecurityAuthenticationCheckEvent()
 {
     string[] counterNames = new string[]
         {
             SecurityServiceEvent.Counters[(int)CounterID.AuthenticationCheck].CounterName
         };
     securityEvent = new SecurityAuthenticationCheckEvent(counterNames);
     writerLock = new ReaderWriterLock();
 }
コード例 #35
0
 static SecurityProfileLoadEvent()
 {
     string[] counterNames = new string[]
         {
             SecurityServiceEvent.Counters[(int)CounterID.ProfileLoad].CounterName
         };
     securityEvent = new SecurityProfileLoadEvent(counterNames);
     writerLock = new ReaderWriterLock();
 }
コード例 #36
0
 private void Initital()
 {
     Reset();
     httpClient          = new HttpClientHelper();
     md5                 = new MD5CryptionXG();
     cacheParamType      = new Dictionary <Type, PropertyInfo[]>(10);
     lockrw              = new ReaderWriterLock();
     httpClient.Encoding = encoder;
 }
コード例 #37
0
        virtual protected void InitMember()
        {
            m_StopPrivilege = new System.Threading.ReaderWriterLock();
            m_OMCAddresses  = new Dictionary <string, string>();
            m_OMCInfo       = new Dictionary <string, string>();
            LogReceived    += new LogHandler(DBAdapterBase_LogReceived);
            StateChanged   += new StateChangeHandler(DBAdapterBase_StateChanged);

            m_TimerMaintenance          = new System.Timers.Timer(3540 * 1000); // 59分钟运行一次的维护定时器
            m_TimerMaintenance.Elapsed += new System.Timers.ElapsedEventHandler(m_TimerMaintenance_Elapsed);
        }
コード例 #38
0
 public PSMoveSharpCameraFrameState()
 {
     camera_frame_state_rwl = new ReaderWriterLock();
     full_image             = new Bitmap(ImageWidth, ImageHeight);
     using (Graphics gfx = Graphics.FromImage(full_image))
         using (SolidBrush brush = new SolidBrush(Color.FromArgb(0, 255, 255)))
         {
             gfx.FillRectangle(brush, 0, 0, ImageWidth, ImageHeight);
         }
     camera_frame_state_collector = new PSMoveSharpCameraFrameStateCollector();
 }
コード例 #39
0
ファイル: PSMoveClient.cs プロジェクト: johhov/DeviceJam
        public PSMoveSharpCameraFrameState()
        {
            camera_frame_state_rwl = new ReaderWriterLock();
            //full_image = new List<byte[]>();

            /*
             * using (Graphics gfx = Graphics.FromImage(full_image))
             * using (SolidBrush brush = new SolidBrush(Color.FromArgb(0, 255, 255)))
             * {
             * gfx.FillRectangle(brush, 0, 0, ImageWidth, ImageHeight);
             * }
             */
            camera_frame_state_collector = new PSMoveSharpCameraFrameStateCollector();
        }
コード例 #40
0
        /// <summary>
        /// Initialize the spreadsheet.
        /// </summary>
        public Spreadsheet(IContainer iContainer)
        {
            // Add this spreadsheet to the list of objects in the container.  When the container is destroyed, all the components,
            // including this one, will be disposed of as well.
            iContainer.Add(this);

            // These objects provide sorting and filtering for the rows and columns.
            this.spreadsheetRowView    = new SpreadsheetRowView(this);
            this.spreadsheetColumnView = new SpreadsheetColumnView(this);

            // This table contains the styles.
            this.styleTable = new Dictionary <string, Style>();

            // This list is used for all the cells that have been animated.  At regular intervals, the style on the cells in this
            // list is changed to make it appear to be changing.  See the 'AnimationThread' for the usage.
            this.animatedList = new AnimatedList();

            // These are the initial dimensions of the spreadsheet and the header.
            this.displayRectangle  = Rectangle.Empty;
            this.headerRectangle   = Rectangle.Empty;
            this.broadcastDataSize = Size.Empty;

            // This lock is used to coordinate input and output from the this data structure.  The document can be read from any
            // number of threads, but when the data model is changed (written to), other threads must be prevented from reading
            // intermediate results.
            this.readerWriterLock = new ReaderWriterLock();

            // This flag is used to terminate the background thread used to animate cells that have changed.  When set to false the
            // background thread will exit.
            this.isAnimationRunning = true;

#if DEBUG
            // Disable the background threads when in the design mode.  They will kill the designer.
            if (LicenseManager.UsageMode != LicenseUsageMode.Designtime)
            {
#endif

            // This thread will refresh the document from the background.  That is, all the hard work is done in the background.
            // Delegates will be called when the data is actually ready to be put in the control.
            this.animationThread              = new Thread(new ThreadStart(AnimationThread));
            this.animationThread.Name         = "AnimationThread";
            this.animationThread.IsBackground = true;
            this.animationThread.Start();

#if DEBUG
        }
#endif
        }
コード例 #41
0
 /// <summary>
 /// Initializes the BallMgr.
 /// </summary>
 /// <returns></returns>
 public static bool Init()
 {
     try
     {
         m_lock     = new System.Threading.ReaderWriterLock();
         _fightRate = new Dictionary <int, FightRateInfo>();
         return(LoadFightRate(_fightRate));
     }
     catch (Exception e)
     {
         if (log.IsErrorEnabled)
         {
             log.Error("AwardMgr", e);
         }
         return(false);
     }
 }
コード例 #42
0
 public static bool Init()
 {
     try
     {
         m_lock   = new System.Threading.ReaderWriterLock();
         _allProp = new Dictionary <int, ItemTemplateInfo>();
         return(LoadProps(_allProp));
     }
     catch (Exception e)
     {
         if (log.IsErrorEnabled)
         {
             log.Error("InitProps", e);
         }
         return(false);
     }
 }
コード例 #43
0
 /// <summary>
 /// Initializes the StrengthenMgr.
 /// </summary>
 /// <returns></returns>
 public static bool Init()
 {
     try
     {
         m_lock          = new System.Threading.ReaderWriterLock();
         _consortiaLevel = new Dictionary <int, ConsortiaLevelInfo>();
         rand            = new ThreadSafeRandom();
         return(Load(_consortiaLevel));
     }
     catch (Exception e)
     {
         if (log.IsErrorEnabled)
         {
             log.Error("ConsortiaLevelMgr", e);
         }
         return(false);
     }
 }
コード例 #44
0
 /// <summary>
 /// Initializes the BallMgr.
 /// </summary>
 /// <returns></returns>
 public static bool Init()
 {
     try
     {
         m_lock           = new System.Threading.ReaderWriterLock();
         _dailyAward      = new Dictionary <int, DailyAwardInfo>();
         _dailyAwardState = false;
         return(LoadDailyAward(_dailyAward));
     }
     catch (Exception e)
     {
         if (log.IsErrorEnabled)
         {
             log.Error("AwardMgr", e);
         }
         return(false);
     }
 }
コード例 #45
0
 /// <summary>
 /// Initializes the BallMgr.
 /// </summary>
 /// <returns></returns>
 public static bool Init()
 {
     try
     {
         m_lock    = new System.Threading.ReaderWriterLock();
         _balls    = new Dictionary <int, BallInfo>();
         _ballTile = new Dictionary <int, Tile>();
         return(LoadBall(_balls, _ballTile));
     }
     catch (Exception e)
     {
         if (log.IsErrorEnabled)
         {
             log.Error("BallMgr", e);
         }
         return(false);
     }
 }
コード例 #46
0
 /// <summary>
 /// Initializes the BallMgr.
 /// </summary>
 /// <returns></returns>
 public static bool Init()
 {
     try
     {
         m_lock   = new System.Threading.ReaderWriterLock();
         _fusions = new Dictionary <string, FusionInfo>();
         rand     = new ThreadSafeRandom();
         return(LoadFusion(_fusions));
     }
     catch (Exception e)
     {
         if (log.IsErrorEnabled)
         {
             log.Error("FusionMgr", e);
         }
         return(false);
     }
 }
コード例 #47
0
 public SettingsLoader()
 {
     try
     {
         this.m_rwlock = new System.Threading.ReaderWriterLock();
         if (!System.IO.File.Exists(this.OptionsFile))
         {
             this.Reset();
         }
         else
         {
             this.LoadOptions();
         }
     }
     catch (System.Exception ex)
     {
         Program.showErrorMessage(ex.Message);
     }
 }
コード例 #48
0
 /// <summary>
 /// Initializes the StrengthenMgr.
 /// </summary>
 /// <returns></returns>
 public static bool Init()
 {
     try
     {
         m_lock                 = new System.Threading.ReaderWriterLock();
         _strengthens           = new Dictionary <int, StrengthenInfo>();
         m_Refinery_Strengthens = new Dictionary <int, StrengthenInfo>();
         Strengthens_Goods      = new Dictionary <int, StrengthenGoodsInfo>();
         rand = new ThreadSafeRandom();
         return(LoadStrengthen(_strengthens, m_Refinery_Strengthens));
     }
     catch (Exception e)
     {
         if (log.IsErrorEnabled)
         {
             log.Error("StrengthenMgr", e);
         }
         return(false);
     }
 }
コード例 #49
0
ファイル: WorldServer.cs プロジェクト: DeKaDeNcE/MangosSharp
 public WorldServer(XmlConfigurationProvider <WorldServerConfiguration> xmlConfigurationProvider)
 {
     CLIENTs                   = new Dictionary <uint, WS_Network.ClientClass>();
     CHARACTERs                = new Dictionary <ulong, WS_PlayerData.CharacterObject>();
     CHARACTERs_Lock           = new System.Threading.ReaderWriterLock();
     ALLQUESTS                 = new WS_Quests();
     AllGraveYards             = new WS_GraveYards(WorldServiceLocator._DataStoreProvider);
     CreatureQuestStarters     = new Dictionary <int, List <int> >();
     CreatureQuestFinishers    = new Dictionary <int, List <int> >();
     GameobjectQuestStarters   = new Dictionary <int, List <int> >();
     GameobjectQuestFinishers  = new Dictionary <int, List <int> >();
     WORLD_CREATUREs_Lock      = new System.Threading.ReaderWriterLock();
     WORLD_CREATUREs           = new Dictionary <ulong, WS_Creatures.CreatureObject>();
     WORLD_CREATUREsKeys       = new ArrayList();
     WORLD_GAMEOBJECTs         = new Dictionary <ulong, WS_GameObjects.GameObject>();
     WORLD_CORPSEOBJECTs       = new Dictionary <ulong, WS_Corpses.CorpseObject>();
     WORLD_DYNAMICOBJECTs_Lock = new System.Threading.ReaderWriterLock();
     WORLD_DYNAMICOBJECTs      = new Dictionary <ulong, WS_DynamicObjects.DynamicObject>();
     WORLD_TRANSPORTs_Lock     = new System.Threading.ReaderWriterLock();
     WORLD_TRANSPORTs          = new Dictionary <ulong, WS_Transports.TransportObject>();
     WORLD_ITEMs               = new Dictionary <ulong, ItemObject>();
     ITEMDatabase              = new Dictionary <int, WS_Items.ItemInfo>();
     CREATURESDatabase         = new Dictionary <int, CreatureInfo>();
     GAMEOBJECTSDatabase       = new Dictionary <int, WS_GameObjects.GameObjectInfo>();
     itemGuidCounter           = WorldServiceLocator._Global_Constants.GUID_ITEM;
     CreatureGUIDCounter       = WorldServiceLocator._Global_Constants.GUID_UNIT;
     GameObjectsGUIDCounter    = WorldServiceLocator._Global_Constants.GUID_GAMEOBJECT;
     CorpseGUIDCounter         = WorldServiceLocator._Global_Constants.GUID_CORPSE;
     DynamicObjectsGUIDCounter = WorldServiceLocator._Global_Constants.GUID_DYNAMICOBJECT;
     TransportGUIDCounter      = WorldServiceLocator._Global_Constants.GUID_MO_TRANSPORT;
     Log                           = new BaseWriter();
     PacketHandlers                = new Dictionary <Opcodes, HandlePacket>();
     Rnd                           = new Random();
     AccountDatabase               = new SQL();
     CharacterDatabase             = new SQL();
     WorldDatabase                 = new SQL();
     this.xmlConfigurationProvider = xmlConfigurationProvider;
 }
コード例 #50
0
ファイル: Table.cs プロジェクト: DonaldAirey/quasar
        /// <summary>
        /// Create a table of in-memory data.
        /// </summary>
        /// <param name="name"></param>
        public Table()
        {
            // Initialize the object.
            this.IsPersistent     = true;
            this.Columns          = new ColumnCollection(base.Columns);
            this.Rows             = new RowCollection(this, base.Rows);
            this.ChildRelations   = new RelationCollection(base.ChildRelations);
            this.ParentRelations  = new RelationCollection(base.ParentRelations);
            this.Indices          = new List <Index>();
            this.ReaderWriterLock = new ReaderWriterLock();

            // IMPORTANT CONCEPT: All rows have a row version which is used to reconcile the client data model with the server
            // data model. When the row version of a server row is newer than the row version on the client, that record and only
            // that record is transmitted to the client.  In this way, the client data model is reconciled to the server data model
            // with a minimum amount of traffic between the two.
            this.RowVersionColumn = new Column("RowVersion", typeof(long), string.Empty, MappingType.Attribute);
            this.RowVersionColumn.IsPersistent = true;
            this.Columns.Add(this.RowVersionColumn);

            // The 'Indicies' is a subset of the constraint collection.  It is often clumsy to search all the constraints looking
            // for just an index, so a list of just the indices is maintained through this event handler.
            this.Constraints.CollectionChanged += new System.ComponentModel.CollectionChangeEventHandler(Constraints_CollectionChanged);
        }
コード例 #51
0
        /// <summary>
        ///  通用输出并记录,主线程
        /// </summary>
        /// <param name="message"></param>
        public static void OutputAndSaveTxt(string message)
        {
            if (!File.Exists(Path.Combine(TheBasePath, "Alloutput.txt")))
            {
                File.Create(Path.Combine(TheBasePath, "Alloutput.txt"));
            }
            ReaderWriterLock rwl = new System.Threading.ReaderWriterLock();

            lock (objectLock)
            {
                rwl.AcquireWriterLock(1000);

                Thread.Sleep(new Random().Next(1000, 2000));
                Console.WriteLine(message);
                File.AppendAllLines(Path.Combine(TheBasePath, "Alloutput.txt"), new List <string>()
                {
                    message
                });
                //File.AppendAllText(Path.Combine(TheBasePath, "Alloutput.txt"), message);
                Thread.Sleep(new Random().Next(1000, 2000));

                rwl.ReleaseWriterLock();
            }
        }
コード例 #52
0
        internal OletxTransactionManager(
            string nodeName
            )
        {
            lock ( ClassSyncObject )
            {
                // If we have not already initialized the shim factory and started the notification
                // thread, do so now.
                if (null == OletxTransactionManager.proxyShimFactory)
                {
                    Int32 error = NativeMethods.GetNotificationFactory(
                        OletxTransactionManager.ShimWaitHandle.SafeWaitHandle,
                        out OletxTransactionManager.proxyShimFactory
                        );

                    if (0 != error)
                    {
                        throw TransactionException.Create(SR.GetString(SR.TraceSourceOletx), SR.GetString(SR.UnableToGetNotificationShimFactory), null);
                    }

                    ThreadPool.UnsafeRegisterWaitForSingleObject(
                        OletxTransactionManager.ShimWaitHandle,
                        new WaitOrTimerCallback(OletxTransactionManager.ShimNotificationCallback),
                        null,
                        -1,
                        false
                        );
                }
            }

            this.dtcTransactionManagerLock = new ReaderWriterLock();

            this.nodeNameField = nodeName;

            // The DTC proxy doesn't like an empty string for node name on 64-bit platforms when
            // running as WOW64.  It treats any non-null node name as a "remote" node and turns off
            // the WOW64 bit, causing problems when reading the registry.  So if we got on empty
            // string for the node name, just treat it as null.
            if ((null != this.nodeNameField) && (0 == this.nodeNameField.Length))
            {
                this.nodeNameField = null;
            }

            if (DiagnosticTrace.Verbose)
            {
                DistributedTransactionManagerCreatedTraceRecord.Trace(SR.GetString(SR.TraceSourceOletx),
                                                                      this.GetType(),
                                                                      this.nodeNameField
                                                                      );
            }

            // Initialize the properties from config.
            configuredTransactionOptions.IsolationLevel = isolationLevelProperty = TransactionManager.DefaultIsolationLevel;
            configuredTransactionOptions.Timeout        = timeoutProperty = TransactionManager.DefaultTimeout;

            this.internalResourceManager = new OletxInternalResourceManager(this);

            dtcTransactionManagerLock.AcquireWriterLock(-1);
            try
            {
                this.dtcTransactionManager = new DtcTransactionManager(this.nodeNameField, this);
            }
            finally
            {
                dtcTransactionManagerLock.ReleaseWriterLock();
            }

            if (resourceManagerHashTable == null)
            {
                resourceManagerHashTable     = new Hashtable(2);
                resourceManagerHashTableLock = new System.Threading.ReaderWriterLock();
            }
        }
コード例 #53
0
ファイル: MacroDropMgr.cs プロジェクト: uvbs/DDTank-3.0
 public static bool Init()
 {
     m_lock   = new System.Threading.ReaderWriterLock();
     FilePath = Directory.GetCurrentDirectory() + @"\macrodrop\macroDrop.ini";
     return(Reload());
 }
コード例 #54
0
ファイル: Row.cs プロジェクト: DonaldAirey/quasar
 /// <summary>
 /// Creates a row.
 /// </summary>
 /// <param name="dataRowBuilder">The System.Data.DataRowBuilder type supports the .NET Framework and is not intended to be
 /// used directly by your code.</param>
 public Row(System.Data.DataRowBuilder dataRowBuilder)
     : base(dataRowBuilder)
 {
     // Initialize the object.
     this.ReaderWriterLock = new ReaderWriterLock();
 }
コード例 #55
0
ファイル: MacroDropMgr.cs プロジェクト: uvbs/DDTank-3.0
 public static bool Init()
 {
     m_lock = new System.Threading.ReaderWriterLock();
     return(ReLoad());
 }
コード例 #56
0
ファイル: LockQueue.cs プロジェクト: pmq20/mono_forked
 public LockQueue(ReaderWriterLock rwlock)
 {
     this.rwlock = rwlock;
 }
コード例 #57
0
 /// <summary>
 /// constructor
 /// </summary>
 public TSystemDefaultsCache() : base()
 {
     FTableCached   = false;
     FReadWriteLock = new System.Threading.ReaderWriterLock();
 }
コード例 #58
0
 public WriterLock(ReaderWriterLock @lock)
 {
     _lock = @lock;
     _lock.AcquireWriterLock(Timeout.Infinite);
 }
コード例 #59
0
 public CommandQueue()
 {
     _lock     = new System.Threading.ReaderWriterLock();
     _commands = new List <Command>();
 }