设置 *** 作超时

设置 *** 作超时,第1张

设置 *** 作超时

您可以在单独的线程中运行该 *** 作,然后在线程连接 *** 作上设置超时

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.");        }    }}


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5440942.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-11
下一篇2022-12-11

发表评论

登录后才能评论

评论列表(0条)

    保存