[ACCEPTED]-Calling a C# method, and make it take 10 seconds to return-multithreading

Accepted answer
Score: 10

You could create a wrapper method which 1 does the appropriate sleep.

Score: 3

Start a new thread that sleeps for 10 sec, then 2 return, that way the time that the methos 1 takes to run won't add to the 10 seconds

using System.Threading;

public static WCF(object obj) 
        Thread newThread = 
            new Thread(new ThreadStart(Work));

        //do method here

        return obj;


    static void Work()
Score: 0

If you mean without changing the code on 3 the other (Server-side) end of the WCF call, (since 2 if you can change the code there then the 1 answer is obvious),

then no..

Score: 0

If this is just for testing, you could have 6 the proxy class point to a web proxy that 5 simulates the timeout. Using Fiddler you could 4 script the request/response to be delayed 3 by 10 seconds and then have the proxy class 2 use Fiddler to make web service requests 1 by setting the "Proxy" property:

IWebProxy proxy = new WebProxy("http://localhost:8888", true);
webService.Proxy = proxy;

More Related questions