Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF Function Continue after return

i have a web application that connects to a windows service via WCF and calls a method. After the method has returned its result (and everything is successfull - see line **?? below) i want the service to continue and do some other work.

What is the easiest way to do this?

thanks Damo

C# Code

//Add Files To Control Manager
    public ReturnClass FilesToControl(List<Item> lstNewItems,string ReferenceNumber,string Type,String Description)
   {
       try
       {
           String ThisisAnItemToControl = "";
           String ThisIsItsType = "";

           for (int i = 0; i < lstNewItems.Count; i++) // Loop through List with for
           {
               ThisisAnItemToControl = lstNewItems[i].Paramater;
               ThisIsItsType = lstNewItems[i].Type;

               // Do a pre check on the item

               // Does File Exist

               if (!File.Exists(ThisisAnItemToControl))
                   return new ReturnClass(-1, ThisisAnItemToControl + " does not exist", String.Empty, null, null, null);  



           }

           return new ReturnClass(1, "", String.Empty, null, null, null);


           // Now that we have returned a result to the web application we can get to work and modify the items under control but how can i do this?

         //  **??


       }

       catch (Exception ex)
       {

           return new ReturnClass(-1, ex.Message.ToString(), "", null, null, null);

       }       
like image 348
user1438082 Avatar asked Nov 29 '25 20:11

user1438082


1 Answers

What I would do is place the extra work in another function. Then, just before you return from the WCF function, create a new thread for the extra work function and run it.

like image 113
System Down Avatar answered Dec 02 '25 08:12

System Down



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!