Repeating a function in C# until it no longer throws an exception

后端 未结 11 2082
一生所求
一生所求 2021-01-18 00:31

I\'ve got a class that calls a SOAP interface, and gets an array of data back. However, if this request times out, it throws an exception. This is good. However, I want m

11条回答
  •  悲&欢浪女
    2021-01-18 00:47

    Although I would NOT recommend you to do this for an infinite number of times, you could make a separate function out of that one sentence:

    void GoConnect()
    {
        try
        {
            salesOrdersArray = MagServ.salesOrderList(sessID, filter);
        }
        catch
        {
            GoConnect();
        }
    }
    

提交回复
热议问题