
您可以在单独的线程中运行该 *** 作,然后在线程连接 *** 作上设置超时:
using System.Threading;class Program { static void DoSomething() { try { // your call here... obj.PerformInitTransaction(); } catch (ThreadAbortException) { // cleanup pre, if needed... } } public static void Main(params string[] args) { Thread t = new Thread(DoSomething); t.Start(); if (!t.Join(TimeSpan.FromSeconds(30))) { t.Abort(); throw new Exception("More than 30 secs."); } }}欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)