当前位置: 首页>>代码示例>>C#>>正文


C# SafeHandles.SafeWaitHandle类代码示例

本文整理汇总了C#中Microsoft.Win32.SafeHandles.SafeWaitHandle的典型用法代码示例。如果您正苦于以下问题:C# SafeWaitHandle类的具体用法?C# SafeWaitHandle怎么用?C# SafeWaitHandle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SafeWaitHandle类属于Microsoft.Win32.SafeHandles命名空间,在下文中一共展示了SafeWaitHandle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CanlibWaitHandle

 public CanlibWaitHandle(object we)
 {
     uint theHandle = (uint) we;
       IntPtr pointer = new IntPtr((long) theHandle);
       SafeWaitHandle swHandle = new SafeWaitHandle(pointer, true);
       base.SafeWaitHandle = swHandle;
 }
开发者ID:mc01104,项目名称:CTR,代码行数:7,代码来源:CanlibWaitHandle.cs

示例2: Semaphore

        public Semaphore(int initialCount, int maximumCount, string name)
        {
            if (initialCount < 0)
            {
                throw new ArgumentOutOfRangeException("initialCount", SR.ArgumentOutOfRange_NeedNonNegNumRequired);
            }

            if (maximumCount < 1)
            {
                throw new ArgumentOutOfRangeException("maximumCount", SR.ArgumentOutOfRange_NeedPosNum);
            }

            if (initialCount > maximumCount)
            {
                throw new ArgumentException(SR.Argument_SemaphoreInitialMaximum);
            }

            if (null != name && MAX_PATH < name.Length)
            {
                throw new ArgumentException(SR.Argument_WaitHandleNameTooLong);
            }
            SafeWaitHandle myHandle = new SafeWaitHandle(Interop.mincore.CreateSemaphoreEx(IntPtr.Zero, initialCount, maximumCount, name, 0, (uint)(Interop.Constants.SemaphoreModifyState | Interop.Constants.Synchronize)), true);

            if (myHandle.IsInvalid)
            {
                int errorCode = (int)Interop.mincore.GetLastError();

                if (null != name && 0 != name.Length && Interop.mincore.Errors.ERROR_INVALID_HANDLE == errorCode)
                    throw new WaitHandleCannotBeOpenedException(SR.Format(SR.Threading_WaitHandleCannotBeOpenedException_InvalidHandle, name));

                throw ExceptionFromCreationError(errorCode, name);
            }

            SafeWaitHandle = myHandle;
        }
开发者ID:tijoytom,项目名称:corert,代码行数:35,代码来源:Semaphore.cs

示例3: Thread

		public static UInt64 Thread(SafeWaitHandle threadHandle)
		{
			UInt64 cycleTime;
			if (!QueryThreadCycleTime(threadHandle, out cycleTime))
				throw new Win32Exception();
			return cycleTime;
		}
开发者ID:zhangz,项目名称:Toolbox,代码行数:7,代码来源:CodeTimer.cs

示例4: Process

		public static UInt64 Process(SafeWaitHandle processHandle)
		{
			UInt64 cycleTime;
			if (!QueryProcessCycleTime(processHandle, out cycleTime))
				throw new Win32Exception();
			return cycleTime;
		}
开发者ID:zhangz,项目名称:Toolbox,代码行数:7,代码来源:CodeTimer.cs

示例5: SetWaitableTimer

 public static extern bool SetWaitableTimer(
     SafeWaitHandle hTimer,
     [In] ref long pDueTime,
     int lPeriod,
     IntPtr pfnCompletionRoutine,
     IntPtr lpArgToCompletionRoutine,
     bool fResume);
开发者ID:narunaru0,项目名称:Umanushi,代码行数:7,代码来源:WakeUPTimer.cs

示例6: RegNotifyChangeKeyValue

 public static extern int RegNotifyChangeKeyValue(
     UIntPtr hKey,
     bool bWatchSubtree,
     uint dwNotifyFilter,
     SafeWaitHandle hEvent,
     bool fAsynchronous
     );
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:7,代码来源:Advapi32.cs

示例7: SoundCaptureBase

        public SoundCaptureBase(SoundCaptureDevice device)
        {
            this.device = device;

            positionEvent = new AutoResetEvent(false);
            positionEventHandle = positionEvent.SafeWaitHandle;
            terminated = new ManualResetEvent(true);
        }
开发者ID:notmasteryet,项目名称:FftGuitarTuner,代码行数:8,代码来源:SoundCaptureBase.cs

示例8: CycleTime

 /// <summary>
 /// Initializes a new instance of the CycleTime class.
 /// </summary>
 /// <param name="trackingThreadTime">
 /// True if you want to track the current thread time. False for the 
 /// process as a whole.
 /// </param>
 /// <param name="handle">
 /// The handle to the process for observing.
 /// </param>
 private CycleTime(Boolean trackingThreadTime, SafeWaitHandle handle)
 {
     this.trackingThreadTime = trackingThreadTime;
     this.handle = handle;
     this.startCycleTime = this.trackingThreadTime
                         ? Thread()
                         : Process(this.handle);
 }
开发者ID:nayato,项目名称:microbenchmarks,代码行数:18,代码来源:Wintellect.cs

示例9: Process

 /// <summary>
 ///     Retrieves the sum of the cycle time of all threads of the specified
 ///     process.
 /// </summary>
 public static ulong Process(SafeWaitHandle processHandle)
 {
     ulong cycleTime;
     if (!QueryProcessCycleTime(processHandle, out cycleTime))
     {
         throw new Win32Exception();
     }
     return cycleTime;
 }
开发者ID:RabbitTeam,项目名称:DotNetty,代码行数:13,代码来源:CycleTime.cs

示例10: Thread

 /// <summary>
 ///     Retrieves the cycle time for the specified thread.
 /// </summary>
 public static ulong Thread(SafeWaitHandle threadHandle)
 {
     ulong cycleTime;
     if (!QueryThreadCycleTime(threadHandle, out cycleTime))
     {
         throw new Win32Exception();
     }
     return cycleTime;
 }
开发者ID:RabbitTeam,项目名称:DotNetty,代码行数:12,代码来源:CycleTime.cs

示例11: ResetEvent

		public static bool ResetEvent (SafeWaitHandle handle)
		{
			bool release = false;
			try {
				handle.DangerousAddRef (ref release);
				return ResetEvent_internal (handle.DangerousGetHandle ());
			} finally {
				if (release)
					handle.DangerousRelease ();
			}
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:11,代码来源:NativeEventCalls.cs

示例12: AbsoluteTimer

        public WaitHandle AbsoluteTimer(DateTimeOffset expireAt)
        {
            var handle = CreateWaitableTimer(IntPtr.Zero, true, null);

            var dueTime = expireAt.ToUniversalTime().ToFileTime();

            SetWaitableTimer(handle, ref dueTime, 0, IntPtr.Zero, IntPtr.Zero, false);

            var safeHandle = new SafeWaitHandle(handle, true);

            return new TimerWaitHandle(safeHandle);
        }
开发者ID:hash,项目名称:trigger.net,代码行数:12,代码来源:Win32Native.cs

示例13: ProcessInfo

        public ProcessInfo(
            Process ps, 
            ProcessInformation psi)
        {
            if (null == ps)
            {
                throw new ArgumentNullException("ps");
            }

            this.ps = ps;
            this.mainThreadHandle = new SafeWaitHandle(
                psi.hThread, 
                true);
        }
开发者ID:gregjhogan,项目名称:ApplicationInsights-server-dotnet,代码行数:14,代码来源:ProcessInfo.cs

示例14: ByteRangeDownloader

        internal ByteRangeDownloader(Uri requestedUri, string tempFileName, SafeWaitHandle eventHandle)
            : this(requestedUri, eventHandle)
        {
            if (tempFileName == null)
            {
                throw new ArgumentNullException("tempFileName");
            }

            if (tempFileName.Length <= 0)
            {
                throw new ArgumentException(SR.Get(SRID.InvalidTempFileName), "tempFileName");
            }

            _tempFileStream = File.Open(tempFileName, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:15,代码来源:ByteRangeDownloader.cs

示例15: EventWaitHandle

        public EventWaitHandle(bool initialState, EventResetMode mode, string name)
        {
            if(null != name && System.IO.Path.MAX_PATH < name.Length)
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_WaitHandleNameTooLong",name));
            }
            Contract.EndContractBlock();
            
            SafeWaitHandle _handle = null;
#if MONO
            int errorCode;
#endif
            switch(mode)
            {
                case EventResetMode.ManualReset:
#if MONO
                    _handle = new SafeWaitHandle (NativeEventCalls.CreateEvent_internal (true, initialState, name, out errorCode), true);
#else
                    _handle = Win32Native.CreateEvent(null, true, initialState, name);
#endif
                    break;
                case EventResetMode.AutoReset:
#if MONO
                    _handle = new SafeWaitHandle (NativeEventCalls.CreateEvent_internal (false, initialState, name, out errorCode), true);
#else
                    _handle = Win32Native.CreateEvent(null, false, initialState, name);
#endif
                    break;

                default:
                    throw new ArgumentException(Environment.GetResourceString("Argument_InvalidFlag",name));
            };
                
            if (_handle.IsInvalid)
            {
#if !MONO
                int errorCode = Marshal.GetLastWin32Error();
#endif
            
                _handle.SetHandleAsInvalid();
                if(null != name && 0 != name.Length && Win32Native.ERROR_INVALID_HANDLE == errorCode)
                    throw new WaitHandleCannotBeOpenedException(Environment.GetResourceString("Threading.WaitHandleCannotBeOpenedException_InvalidHandle",name));

                __Error.WinIOError(errorCode, name);
            }
            SetHandleInternal(_handle);
        }
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:47,代码来源:eventwaithandle.cs


注:本文中的Microsoft.Win32.SafeHandles.SafeWaitHandle类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。