Click here to Skip to main content
12,825,743 members (37,554 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# threads
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;
                rt = CaptureAllInvoices();
                if (rt)

                        Write2ErrLog("------Email Invoices Started-" + DateTime.Now);
                        Write2ErrLog("------Email Invoices Completed-" + DateTime.Now);

                        Write2ErrLog("------Email Single Invoices Started-" + DateTime.Now);
                        Write2ErrLog("------Email Single Invoices Completed-" + DateTime.Now);

                        Write2ErrLog("------Fax Invoices Started-" + DateTime.Now);
                        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

Posted 28-Jan-13 10:39am
Updated 28-Jan-13 10:42am
DinoRondelly 28-Jan-13 15:43pm
Where is the code thats in this.EmailInvoices()?
richcb 28-Jan-13 15:44pm
What value does your CaptureAllInvoices() method return?
Saamir 28-Jan-13 15:48pm
boolean true or false. Capture invoices just populates the table and if no errors then true is returned
Saamir 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 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 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.
Saamir 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.
DinoRondelly 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 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 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,
jibesh 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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170308.1 | Last Updated 28 Jan 2013
Copyright © CodeProject, 1999-2017
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