Tasks error RRS feed

  • Question

  • User-776477372 posted

    Hi friend,

    i am using task factory for request two method (sendRequestMethod1 and sendRequestMethod2). SendRequestMethod1 method take time 10 second and sendRequestMethod2 take 30 to 40 second time. During this request i got error message. this is multi treading request by user. 

    private Object LockRequestAMWS = new Object();
    lock (LockRequestAMWS)
    cancellationtoken[] ct = new cancellationtoken[2];
    task<string>[] tasks = new task<string>[2];
    cancellationtoken cts = new cancellationtoken();
    tasks[0] = task.factory.startnew(() => sendRequestMethod1("abc"), ct[0]);
    tasks[1] = task.factory.startnew(() => sendRequestMethod2("abc"), ct[1]);
    _response = tasks[0].result;
    string respons2 = tasks[1].result;
    task.waitall(tasks, cts);

    Error :-

    Error Message :-One or more errors occurred.
    Error Source :-mscorlib
    Error StackTrace :- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at System.Threading.Tasks.Task`1.get_Result()
    Error TargetSite :-Void ThrowIfExceptional(Boolean)
    Error InnerException :-
    Error BaseException().Message :-The operation has timed out

    Tuesday, September 17, 2013 3:25 AM

All replies

  • User-488622176 posted

    What are the "sendRequestMethod1" and "sendRequestMethod2" methods? Do they call webservices or WCF services? If so, you'll need to change the connection timeout values. See http://stackoverflow.com/questions/424358/increasing-the-timeout-value-in-a-wcf-service 

    Wednesday, September 18, 2013 9:37 AM
  • User-776477372 posted

    Hi Illeris,

    i am working in WCF services.

    "sendRequestMethod1" and "sendRequestMethod2" are method which is send the request to other service. "sendRequestMethod1" method request to "Amadues services" and "sendRequestMethod2" request to "WorldSpan services".  "SendRequestMethod1" getting response time only 10 Second  and "sendRequestMethod2" getting response time only 20 second. 

    Thursday, September 19, 2013 1:19 AM
  • User-488622176 posted

    In this case I think the timeout applies to one of the two methods. Increasing the default timeout value can solve the issue:

    See http://stackoverflow.com/questions/1520283/wcf-service-how-to-increase-the-timeout for a concrete example on how to modify the config file settings.

    Thursday, September 19, 2013 7:27 AM