I would like to hook into this question, however perhaps rephrase it from a different angle.

For anti fraud purposes I would like to block visitors after a certain amount of incorrect login attempts. At this point I have a manager class which wraps the actual function call to login. The manager throws an exception if a visitor is blocked and thus the actual login method is never called. So far so good.

I would now like to change the exception throwing part to a Thread.Sleep kind of thingy. This is not an option however because this will block other requests to the server. Is there an easy alternative for this scenario perhaps using some async wait command or perhaps using F#?

Current code:

class Manager {
    void Execute(Action action) {
        if(user.IsBlocked)
            throw new BlockedException();
        else
            action();
    }
}

Preferred code:

class Manager {
    void Execute(Action action) {
        if(user.IsBlocked)
            //Wait for xxx minutes


        action();
    }
}

没有正确的解决方案

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top