Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Threading function
Hi guys,
Please help!!!! I have a function that I am calling to automate processing of invoices. Most of the times this function works without issues but from time to time it hangs. i.e.
Here is the function:
public void ProcessInvoices()
        {
            bool rt = true;
            try
            {
                rt = CaptureAllInvoices();
                if (rt)
                {
 
                        Write2ErrLog("------Email Invoices Started-" + DateTime.Now);
                        this.EmailInvoices();
                        Write2ErrLog("------Email Invoices Completed-" + DateTime.Now);
 

                        Write2ErrLog("------Email Single Invoices Started-" + DateTime.Now);
                        this.EmailSingleInvoices();
                        Write2ErrLog("------Email Single Invoices Completed-" + DateTime.Now);
 
                        Write2ErrLog("------Fax Invoices Started-" + DateTime.Now);
                        this.FaxInvoices(false);
                        Write2ErrLog("------Fax Invoices Completed-" + DateTime.Now);
 
                }
            }
            catch (Exception ex)
            {
                Write2ErrLog("---------Error in Process invoices: " + ex.Message);
            }
        }
 
So it gets to this.EmailInvoices() and starts processing email but stops on the first one and doesn't move to the next function call.
 
Please advice on an approach I can take to troubleshoot this issue. I use try catch in all my functions but nothing is being caught.
 
Thanks in advance
 
Sam
Posted 28-Jan-13 9:39am
Saamir477
Edited 28-Jan-13 9:42am
5.1K
v2
Comments
DinoRondelly at 28-Jan-13 15:43pm
   
Where is the code thats in this.EmailInvoices()?
Saamir at 28-Jan-13 15:49pm
   
it's long code that processes one invoice at a time by generating an invoice, attaching to an email and then emailing. Then loops to another invoice
DinoRondelly at 28-Jan-13 15:51pm
   
And you are sure its not getting "hung up" in there?
 
Have you stepped through the code and seen it hung up?
Saamir at 28-Jan-13 15:56pm
   
Haven't done that, this function will work if I try it again for the same data output. This is a random behavior.
DinoRondelly at 28-Jan-13 15:59pm
   
I would suggest stepping through it until it fails, its going to be hard if not impossible to determine the problem with the code sample you have provided.
Saamir at 28-Jan-13 16:00pm
   
how do I step through with the service calling the function. Should I call the function from a windows form or is there a different method?
DinoRondelly at 28-Jan-13 16:12pm
   
The problem is going to be in EmailInvoices function somewhere IMO, so however you decide to debug this its your best chance and finding the problem. Might take a bit of work to set up a test application but you should be able to atleast see whats getting stuck and why.
 
Looking at what you supplied i have no idea whats happen and would be impressed if anyone else could figure that out from that code sample,
Saamir at 28-Jan-13 15:58pm
   
From the data status updates from emailinvoice function, it is starting to email and then just hangs there on the first one. it's almost like the windows service stops the initial processinvoice call.
richcb at 28-Jan-13 15:44pm
   
What value does your CaptureAllInvoices() method return?
Saamir at 28-Jan-13 15:48pm
   
boolean true or false. Capture invoices just populates the table and if no errors then true is returned
jibesh at 28-Jan-13 16:20pm
   
There isnt too much information in the code you provided , its just the function calls and we cannot workout anything with limited information. You can add more logs to you method calls to know which method/line last called and got hanged. If you are sure its the first method 'EmailInvoices' do a though analysis this method and you may copy the code so that someone can check what went wrong. its tough otherwise to find what went wrong.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Gihan Liyanage 332
1 Sergey Alexandrovich Kryukov 330
2 ClimerChinna 222
3 vikinghunter 168
4 OriginalGriff 166
0 Sergey Alexandrovich Kryukov 8,363
1 OriginalGriff 7,112
2 CPallini 2,598
3 Richard MacCutchan 2,025
4 Abhinav S 1,788


Advertise | Privacy | Mobile
Web01 | 2.8.140827.1 | Last Updated 28 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100