Sunday 15 March 2015

c# - Task.Delay bugged or am I doing something wrong? -


Edit: I was doing something wrong, with time-time objects coding execution and instead of total emilicend Milliseconds was to be out

In short, I have a new MVC 4 project running on .NET 4.5 with the following code in the Home Controller. Public Emission Tasks & lt; Actionsclass & gt; Index () {int32 [] delay = new int 32 [] (1999, 500, 20); List of & lt; string & gt; Results = New list & lt; string & gt; (); Var now = datetime Now add the result (string.format ("start {0}", now.tostring ("MM / dd / yyyy hh: mm: ss.fff tt")); // get 1 result.Add (" 1) Wait for the job, when all (select delay (select async x => result (wait slow (x, now, array index (delay, x), "1 le") )); // Get 2 results ("Take 2"); Var function = delay. Selection ((x, i) => slower (x, now, i, "2 le"). ToList (); awaiting work. Select the action (x = & gt; x.Result)); Return View (Results);}

My slow method looks like this ...

  Private async Tasks & lt; string & gt; Slow (Int32 ms, DateTime dt, int i, string string) {Response.Write (String.Format ("[{3}] [index: {0} Delay: {2}} Pre-sleep - {1} 
, i, DateTime.ToString ("MM / dd / yyyy hh: mm: ss.fff tt"), MS, LE )); Awaiting work Daley (MS); Response. White (string.format ("[{3}] [index: {0}] [delayed {2}} after sleep - {1}
, I, Datetime. Now.ToString ( "MM / DD / YY HH: mm: SSFTTT"), MS, LE)); Var delayed time = date time.Now; Var diff = Delay time - dt; Return String.format ("For Sale: [{2}] {0} Milliseconds. The difference was: {1}", MS, Diff.milyskunds, LE); }

The output looks like this ...

  [take 1] [index: 0] [delay: 1999] pre-sleep - 06 / 21/2013 02: 46: 25.338 Prime Minister [le 1] [index: 1] [delay: 500] pre-sleep - 06/21/2013 02: 46: 25.340 pm [le 1] [index: 2] [delay: 20 ] Pre-sleep - 06/21/2013 02: 46: 25.340 pm [Le 1] [index: 2] [delay: 20] after sleep - 06/21/2013 02: 46: 25.368 PM [LE1] [index : 1] [After sleep: 500] after sleep - 06/21/2013 02: 46: 25.849 Pember [Le 1] [index: 0] [delay: 1999] after sleep - 06/21/2013 02: 46: 27.347 PM [le 2] [indexing Of: 0] [Delay: 1 999] Pre sleep - 06/21/2013 02: 46: 27.347 PM [le 2] [index: 1] [delay: 500] East sleep - 06/21/2013 02: 46: 27.347 PM [index 2] [late: 20] former sleep - 06/21/2013 02: 46: 27.347 PM [LE 2] [index: 2] [delay: 20] after sleep - 06 21 PM [LE 2] [index: 1] [delay: 500] after sleep - 06/21/2013 02: 46: 27.861 PM [LE 2] [INDEX: 0] [late] : 1999] After sleeping - 06/21/2013 02: 46: 29.359 AM: 06/21/2013 02: 46: 25.336 Take 1 slip for the Prime Minister: [1] 20 milliseconds was the difference: for 32 Soya: [Take 1] 500 m Lisekend. The difference was: Soya for 513: [LE 1] 1999 milliseconds was the difference: take 2 to sleep: [2L]] 1990 milliseconds difference: Soy for 23: [2 LE] 500 milliseconds was the difference : Rider for 525: [2 le] 20 milliseconds difference: 46   

I am quite surprised by the fact that the delay of 1990 milliseconds shows that it is 5 million seconds After the end, because the other two delays begin to work just fine. I get this behavior as soon as the delay parameter '999' is above the millisecond.

My question is whether I am doing something wrong, if the delay is being reported to the configuration. If the method is pest.

diff.milliseconds MS Component measurements might mean you mean:

  different milliseconds    

No comments:

Post a Comment