This is a migrated thread and some comments may be shown as answers.

Timer doesn't work with if statement.

0 Answers 51 Views
Fiddler Classic
This is a migrated thread and some comments may be shown as answers.
jaemin
Top achievements
Rank 1
jaemin asked on 05 Jan 2020, 05:21 AM

class handlers

{

    static var oTimer: System.Windows.Forms.Timer = new Timer();
    public static ToolsAction("Request by Timer")
    function doIt()
    {
        oTimer = new Timer();
        oTimer.add_Tick(OnTimer);
        oTimer.Interval = 5000;
        oTimer.Start();
    }

    public static ToolsAction("Stop Timer")
    function stopIt()
    { 
        oTimer.Stop();
    }

        
    public static function OnTimer(sender: Object, ea: EventArgs)
    {
        var s = "GET blah blah";
        try{ 
            FiddlerObject.utilIssueRequest(s); 
        } 
        catch(e){ 
            MessageBox.Show("send failed" + e.ToString()); 
        }
    }

    static function OnBeforeResponse(oSession: Session) {

        if (oSession.utilFindInResponse("request start", false)>-1)
        {
            doIt();
        }

        if (oSession.utilFindInResponse("request stop", false)>-1)
        {
            stopIt();
        }

}

}

 

"Tool" -> "Request by timer" and "Stop Timer" works fine.

stopit(); wokrs fine too in if statement.

But doIt(); doesn't work in if statement.

I'm not good at computer thing and English too.

I can't figure out what's wrong. 

Please help and thank you in advance.

No answers yet. Maybe you can help?

Tags
Fiddler Classic
Asked by
jaemin
Top achievements
Rank 1
Share this question
or