question

Upvotes
Accepted
36 4 3 14

What is the difference between GetInflightStatusAsync and GetInflightStatus

Greetings all

Could u kindly help me to explain the difference please?

When and how to use the function with Async?

tick-history-rest-apiasynchronous
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Upvotes
Accepted
7.6k 15 6 9

@Leon.Hong

Are you using C# with WCF?

If my understand is correct, original WSDL does not have method GetInflightStatusAsync. I think the method was generate by WCF. You can open WSDL file with SOAP UI to see original SOAP methods provided by TRTH service.

Normally if you add WCF Service Reference, .NET automatically generate method end with Async keyword for using with Async/Await feature (asynchronous call). It could help in many case for example when calling the method in UI/Web interface and it take long time to get the result. Please find more details about Async/Await from MSDN.

However if you want to try the method the following small console example codes might help.

class Program
    {
      static void Main(string[] args)
      {
            try
            {
		System.Console.WriteLine("Get Inflight Status...");	
                var T = GetInflight();
                T.Wait();
                System.Console.WriteLine("Inflight Active/Limit={0}/{1}", 
                T.Result.status.active, T.Result.status.limit);      
            }
            catch (Exception e)
            {
                System.Console.WriteLine("Exception: {0}", e.Message);
            }
      }
       
      static async Task<TRTHService.GetInflightStatusResponse> GetInflight()
       {
          TRTHService.TRTHApiClient client = new TRTHService.TRTHApiClient();
          TRTHService.CredentialsHeader cred = 
          new TRTHService.CredentialsHeader() { username = "<Username>", 
                                                password = "<Password>" };
          client.CleanUp(ref cred);
          return await client.GetInflightStatusAsync(cred);     
       }
    }

Output
Get Inflight Status...
Inflight Active/Limit=0/50
Press any key to continue . . .


icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.