public DbThreadID SetThrdID() { DbThreadID threadID; int pid = Process.GetCurrentProcess().Id; uint tid = (uint)AppDomain.GetCurrentThreadId(); threadID = new DbThreadID(pid, tid); return threadID; }
private static string doThreadName(IntPtr env, int pid, uint tid, ref string buf) { DB_ENV dbenv = new DB_ENV(env, false); DbThreadID id = new DbThreadID(pid, tid); string ret = dbenv.api2_internal.threadNameHandler(id); try { buf = ret; } catch (NullReferenceException) { /* * The library may give us a NULL pointer in buf and there's no * good way to test for that. Just ignore the exception if * we're not able to set buf. */ } return ret; }
public bool ThrdAlive(DbThreadID info, bool procOnly) { Process pcs = Process.GetProcessById(info.processID); if (pcs.HasExited == true) return false; else if (procOnly) return true; ProcessThreadCollection thrds = pcs.Threads; foreach (ProcessThread pcsThrd in thrds) { if (pcsThrd.Id == info.threadID) { /* * We have to use the fully qualified name, ThreadState * defaults to System.Threading.ThreadState. */ return (pcsThrd.ThreadState != System.Diagnostics.ThreadState.Terminated); } } // If we can't find the thread, we say it's not alive return false; }
private static int doIsAlive(IntPtr env, int pid, uint tid, uint flags) { DB_ENV dbenv = new DB_ENV(env, false); DbThreadID id = new DbThreadID(pid, tid); bool procOnly = (flags == DbConstants.DB_MUTEX_PROCESS_ONLY); return dbenv.api2_internal.isAliveHandler(id, procOnly) ? 1 : 0; }