slightlyoff
asked on
VB.NET System.Threading.Sleep
I have a program that downloads orders into QuickBooks using QuickBooks SDK.
Every now and then, while updating a customer's information, I get an error saying that the Customer's ListID is currently in use.
Normally, the program just tries to run the update again. After 8 times, it quits trying and skips the order.
I've found that a short delay will typically allow the Customer to be update. For example, if I shut the program down after the 8 restarts, and reopen the program, the Customer updates with no issues.
This happens inside of a class called CustomerPC, which is called by the Main form. Here's the calls the Update sub to run again:
I think the issue is that it takes only a second for it to retry 8 times, not enough time for the customer to be released from whatever process is using it. So I was thinking of changing it to this:
Since this program is being used right now and testing it involves messing with orders and accounting software, I wanted to make sure that it behaves as I'm expecting.
Thank you for your help!!!
Every now and then, while updating a customer's information, I get an error saying that the Customer's ListID is currently in use.
Normally, the program just tries to run the update again. After 8 times, it quits trying and skips the order.
I've found that a short delay will typically allow the Customer to be update. For example, if I shut the program down after the 8 restarts, and reopen the program, the Customer updates with no issues.
This happens inside of a class called CustomerPC, which is called by the Main form. Here's the calls the Update sub to run again:
If Main.RestartX < numRestartTimes then 'numRestartTimes is a constant set to 8
UpdateCustomer()
Exit Sub
Else
Main.RestartX = 0
Main.ExitMe()
Exit Sub
End if
I think the issue is that it takes only a second for it to retry 8 times, not enough time for the customer to be released from whatever process is using it. So I was thinking of changing it to this:
If Main.RestartX < numRestartTimes then 'numRestartTimes is a constant set to 8
System.Threading.Sleep(10000) 'force it to wait 10 seconds before trying again
UpdateCustomer()
Exit Sub
Else
Main.RestartX = 0
Main.ExitMe()
Exit Sub
End if
Since this program is being used right now and testing it involves messing with orders and accounting software, I wanted to make sure that it behaves as I'm expecting.
Thank you for your help!!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The issue with this particular problem is there's no rhyme or reason to it, I know what the problem is doing - but I can't duplicate it on purpose. I'll look for ways to test it though, I don't want any weird side effects.
Thank you for your help!