try
{
//try enter Obj within timespan senconds.
if (System.Threading.Monitor.TryEnter(Obj, TimeSpan.FromSeconds(timespan)))
{
//do something with Obj
}
}
catch (Exception e)
{
this.dispInfo(e.Message);
return;
}
finally
{
Monitor.Exit(Obj); //不管是正常还是发生错误,都得释放对象
}