Пример #1
0
        /// <summary>
        /// Terminates <see cref="Thread"/> with ID specified.
        /// </summary>
        /// <param name="id">ID of the <see cref="Thread"/> to terminate.</param>
        /// <returns><see langword="true"/> if thread was successfully terminated;
        /// <see langword="false"/> otherwise.</returns>
        public static bool TerminateThread(int id)
        {
            var handle = NativeCall.OpenThread(0x40000000, false, (uint)id);
            var result = NativeCall.CancelSynchronousIo(handle);

            NativeCall.CloseHandle(handle);
            return(result);
        }