private void StopTracing() { if (this.traceHandle != null) { this.traceHandle.Dispose(); this.traceHandle = null; } if (this.sessionHandle != null) { this.sessionHandle.Dispose(); this.sessionHandle = null; } // Once the unmanaged resources got released, end the process trace thread // that may throw exception (e.g. OOM). if (this.processEventsDelgate != null && this.asyncResult != null) { this.processEventsDelgate.EndInvoke(this.asyncResult); } }
private void StopTracing() { if (this.traceHandle != null) { this.traceHandle.Dispose(); this.traceHandle = null; } if (this.sessionHandle != null) { this.sessionHandle.Dispose(); this.sessionHandle = null; } // Once the unmanaged resources got released, end the process trace thread // that may throw exception (e.g. OOM). if (this.processEventsDelgate != null && this.asyncResult != null) { this.processEventsDelgate.EndInvoke(this.asyncResult); } }
private void StartTracing() { const uint RealTime = 0x00000100; const uint EventRecord = 0x10000000; const uint BufferSize = 64; const uint MinBuffers = 20; const uint MaxBuffers = 200; const uint FlushTimerSeconds = 1; int status; if (!LoadExistingEventTraceProperties()) { this.eventTraceProperties.SetParameters(RealTime, BufferSize, MinBuffers, MaxBuffers, FlushTimerSeconds); // Start trace session ulong unsafeSessionHandle; status = NativeMethods.StartTrace(out unsafeSessionHandle, this.loggerName, ref this.eventTraceProperties); if (status != 0) { throw new System.ComponentModel.Win32Exception(status); } this.sessionHandle = new SessionSafeHandle(unsafeSessionHandle, this.loggerName); Guid EmptyGuid = Guid.Empty; Version Windows7Version = new Version(6, 1, 7600); if (Environment.OSVersion.Version.CompareTo(Windows7Version) >= 0) { const int TimeToWaitForInitialize = 10 * 1000; EnableTraceParameters enableParameters = new EnableTraceParameters(); enableParameters.Version = 1; // ENABLE_TRACE_PARAMETERS_VERSION enableParameters.EnableProperty = EventEnableProperty.Sid; status = NativeMethods.EnableTraceEx2( unsafeSessionHandle, ref this.eventProviderId, 1, // controlCode - EVENT_CONTROL_CODE_ENABLE_PROVIDER (byte)this.Level, this.MatchAnyKeyword, 0, // matchAnyKeyword TimeToWaitForInitialize, ref enableParameters); } else { status = NativeMethods.EnableTraceEx( ref this.eventProviderId, ref EmptyGuid, // sourceId unsafeSessionHandle, 1, // isEnabled (byte)this.Level, this.MatchAnyKeyword, 0, // matchAllKeywords EventEnableProperty.Sid, IntPtr.Zero); } if (status != 0) { throw new System.ComponentModel.Win32Exception(status); } } this.logFile = new EventTraceLogfile(); this.logFile.LoggerName = this.loggerName; this.logFile.EventRecordCallback = EventRecordCallback; this.logFile.ProcessTraceMode = EventRecord | RealTime; ulong unsafeTraceHandle = NativeMethods.OpenTrace(ref this.logFile); status = Marshal.GetLastWin32Error(); if (status != 0) { throw new System.ComponentModel.Win32Exception(status); } this.traceHandle = new TraceSafeHandle(unsafeTraceHandle); this.processEventsDelgate = new ProcessTraceDelegate(ProcessTraceInBackground); this.asyncResult = this.processEventsDelgate.BeginInvoke(this.traceHandle, null, this.processEventsDelgate); }
private void StartTracing() { const uint RealTime = 0x00000100; const uint EventRecord = 0x10000000; const uint BufferSize = 64; const uint MinBuffers = 20; const uint MaxBuffers = 200; const uint FlushTimerSeconds = 1; int status; if (!LoadExistingEventTraceProperties()) { this.eventTraceProperties.SetParameters(RealTime, BufferSize, MinBuffers, MaxBuffers, FlushTimerSeconds); // Start trace session ulong unsafeSessionHandle; status = NativeMethods.StartTrace(out unsafeSessionHandle, this.loggerName, ref this.eventTraceProperties); if (status != 0) { throw new System.ComponentModel.Win32Exception(status); } this.sessionHandle = new SessionSafeHandle(unsafeSessionHandle, this.loggerName); Guid EmptyGuid = Guid.Empty; Version Windows7Version = new Version(6, 1, 7600); if (Environment.OSVersion.Version.CompareTo(Windows7Version) >= 0) { const int TimeToWaitForInitialize = 10 * 1000; EnableTraceParameters enableParameters = new EnableTraceParameters(); enableParameters.Version = 1; // ENABLE_TRACE_PARAMETERS_VERSION enableParameters.EnableProperty = EventEnableProperty.Sid; status = NativeMethods.EnableTraceEx2( unsafeSessionHandle, ref this.eventProviderId, 1, // controlCode - EVENT_CONTROL_CODE_ENABLE_PROVIDER (byte)this.Level, this.MatchAnyKeyword, 0, // matchAnyKeyword TimeToWaitForInitialize, ref enableParameters); } else { status = NativeMethods.EnableTraceEx( ref this.eventProviderId, ref EmptyGuid, // sourceId unsafeSessionHandle, 1, // isEnabled (byte)this.Level, this.MatchAnyKeyword, 0, // matchAllKeywords EventEnableProperty.Sid, IntPtr.Zero); } if (status != 0) { throw new System.ComponentModel.Win32Exception(status); } } this.logFile = new EventTraceLogfile(); this.logFile.LoggerName = this.loggerName; this.logFile.EventRecordCallback = EventRecordCallback; this.logFile.ProcessTraceMode = EventRecord | RealTime; ulong unsafeTraceHandle = NativeMethods.OpenTrace(ref this.logFile); status = Marshal.GetLastWin32Error(); if (status != 0) { throw new System.ComponentModel.Win32Exception(status); } this.traceHandle = new TraceSafeHandle(unsafeTraceHandle); this.processEventsDelgate = new ProcessTraceDelegate(ProcessTraceInBackground); this.asyncResult = this.processEventsDelgate.BeginInvoke(this.traceHandle, null, this.processEventsDelgate); }
internal static extern IntPtr Close(SessionSafeHandle session);
private void StartTracing() { const uint RealTime = 0x00000100; const uint EventRecord = 0x10000000; const uint BufferSize = 64; const uint MinBuffers = 20; const uint MaxBuffers = 200; const uint FlushTimerSeconds = 1; int status; if (!LoadExistingEventTraceProperties()) { _eventTraceProperties.SetParameters(RealTime, BufferSize, MinBuffers, MaxBuffers, FlushTimerSeconds); // Start trace session ulong unsafeSessionHandle; status = NativeMethods.StartTrace( out unsafeSessionHandle, _loggerName, ref _eventTraceProperties); if (status != 0) { throw new Win32Exception(status); } _sessionHandle = new SessionSafeHandle(unsafeSessionHandle, _loggerName); var emptyGuid = Guid.Empty; var windows7Version = new Version(6, 1, 7600); if (Environment.OSVersion.Version.CompareTo(windows7Version) >= 0) { const int TimeToWaitForInitialize = 10 * 1000; var enableParameters = new EnableTraceParameters { Version = 1, EnableProperty = EventEnableProperty.Sid }; // ENABLE_TRACE_PARAMETERS_VERSION status = NativeMethods.EnableTraceEx2( unsafeSessionHandle, ref _eventProviderId, 1, // controlCode - EVENT_CONTROL_CODE_ENABLE_PROVIDER (byte)Level, MatchAnyKeyword, 0, // matchAnyKeyword TimeToWaitForInitialize, ref enableParameters); } else { status = NativeMethods.EnableTraceEx( ref _eventProviderId, ref emptyGuid, // sourceId unsafeSessionHandle, 1, // isEnabled (byte)Level, MatchAnyKeyword, 0, // matchAllKeywords EventEnableProperty.Sid, IntPtr.Zero); } if (status != 0) { throw new Win32Exception(status); } } _logFile = new EventTraceLogfile { LoggerName = _loggerName, EventRecordCallback = EventRecordCallback, ProcessTraceMode = EventRecord | RealTime }; var unsafeTraceHandle = NativeMethods.OpenTrace(ref _logFile); status = Marshal.GetLastWin32Error(); if (status != 0) { throw new Win32Exception(status); } _traceHandle = new TraceSafeHandle(unsafeTraceHandle); _processEventsDelgate = ProcessTraceInBackground; _asyncResult = _processEventsDelgate.BeginInvoke(_traceHandle, null, _processEventsDelgate); }
internal static extern IntPtr Endpoints(SessionSafeHandle session);
internal static extern FutureSafeHandle GetService(SessionSafeHandle session, string name);
internal static extern FutureSafeHandle Register_service(SessionSafeHandle session, string name, ObjectSafeHandle qiObject);
internal static extern FutureSafeHandle Unregister_service(SessionSafeHandle session, uint idx);
internal static extern FutureSafeHandle ListenStandalone(SessionSafeHandle session, string address);
internal static extern int IsConnected(SessionSafeHandle session);
internal static extern int SetIdentity(SessionSafeHandle session, string key, string crt);
internal static extern FutureSafeHandle Connect(SessionSafeHandle session, string address);
public Session() { this._handle = SessionNative.Create(); }