Monitor Program For Crashes

HI all,

I have written a program that trades Forex for me that connects to my broker via an API interface.

As the program can run for days at a time un monitoried I need to know if the program crashes and if it does restart it.

I know this is band aid fix and I should just fix why it crashes. The thing is I can not find out why it crashes every now and then and until i do I want to use the band aid.

It is a multi threaded app and from what I can see it has all the correct error handling in place. If an error occours it will log it to my database so I can review the errors when required.

There seams to be one error that I can not track down and causes the program to freeze randomly. I either need another program to ensure the main one is still running and if not restart it or a better way to track down the errrors when they happen.

Any suggstions

Thanks




Answer this question

Monitor Program For Crashes

  • CBColin

    Without trying the .bat file option I do not think it will work becase when the program crashes it more so just freezes or the windows error box comes up.

    The app is still in task manager so it will appear as if it is still running. Correct me if I am worng as this would be an easy fix for the problem.

    The event log just shows

    Faulting application marvinv2.exe, version 1.0.0.0, faulting module fxclient.dll, version 0.0.0.0, fault address 0x0001afc4.

    fxclient.dll is the third party API is use marvinv2.exe is my app.

    The dll is just imported at the top of each page as 'Imports fxClientAPI'

    The program is basicly a loop that goes to the server every three seconds gets the current price calculates everything required then does nothing or places a trade.

    In the ideal world it would run for a week unattended.

    It is costiing me big$ now as I am missing trade that would be making serious cash. Last night I missed out on about 8k! because it was unstable!

    Would C# be a better option for this type of program

    TIA



  • Asif Shehzad

    Hi, have you already captured the

    Application.ThreadException and the AppDomain.CurrentDomain.UnhandledException events

    These might be able to help you in finding that rare bug.

    Searching for either of these two will give you lots of articles about them.

    I have no real advice for auto-restarting the application, but I believe in theory, by using 2 AppDomains in your application, you would be able to achieve the desired result: i.e. your app starts and .NET creates the Default AppDomain. you create your own new AppDomain, and set it to start you application. When that crash occurs, you unload the created AppDomain, and recreate it again.

    Again, there are plenty of articles around tha should be able to help you further on this track.


  • KumarG

    Runforever.bat:
    :again
    start /wait myapp.exe
    goto again



  • Emanuel Dejanu

    Thanks for both ideas. I checkd the event log and it said it was an issue with the API dll. So I may have done everthing write at my end after all. (if that's possible anyway)

    I will have a look at the thread domain stuff as well. It's all new to me so google here we come.

    As band aid for the moment. I wrote another program that checks a registry value written by the other program eveyr 2 min. If it is greater then 2min then it will start a new instance of the other app.




  • JEROMEMAS

     

    Check your system event log. Often believe it or not it has good information on these things.



  • velmurugan B

    I have spoken the dll venderos but it is a bit hard to say it just freezes every now and then. I don;t have much to give them.

    Is there a way to get .Net to log all errors

    I don't believe it is a broken parmenter as it can run for 12+ hrs at a time no probem then will just freeze.

    With the C# I was more asking if C# would be better than vb.net for this type of program rather than as a solution for this one problem.

    Thanks


  • Dillon

    Want to show us the API declaration

    and the code that calls it



  • Saurabh Mahajan

    Nope, I will go out on a limb and say that C# won't bail you out here... from the event log message, it sounds as if either the 3rd party dll has a problem, or that you are calling the 3rd party dll with some broken parameters...

    Have you tried contacting whoever wrote the fxClientAPI goo

    Best regards,
    Johan Stenberg



  • Monitor Program For Crashes