Is DateTime.Now the best way to measure a function’s performance? [closed]

No, it’s not. Use the Stopwatch (in System.Diagnostics) Stopwatch sw = Stopwatch.StartNew(); PerformWork(); sw.Stop(); Console.WriteLine(“Time taken: {0}ms”, sw.Elapsed.TotalMilliseconds); Stopwatch automatically checks for the existence of high-precision timers. It is worth mentioning that DateTime.Now often is quite a bit slower than DateTime.UtcNow due to the work that has to be done with timezones, DST and such. … Read more

WCF – How to Increase Message Size Quota

You’ll want something like this to increase the message size quotas, in the App.config or Web.config file: <bindings> <basicHttpBinding> <binding name=”basicHttp” allowCookies=”true” maxReceivedMessageSize=”20000000″ maxBufferSize=”20000000″ maxBufferPoolSize=”20000000″> <readerQuotas maxDepth=”32″ maxArrayLength=”200000000″ maxStringContentLength=”200000000″/> </binding> </basicHttpBinding> </bindings> And use the binding name in your endpoint configuration e.g. … bindingConfiguration=”basicHttp” … The justification for the values is simple, they are sufficiently … Read more

Asynchronously wait for Task to complete with timeout

How about this: int timeout = 1000; var task = SomeOperationAsync(); if (await Task.WhenAny(task, Task.Delay(timeout)) == task) { // task completed within timeout } else { // timeout logic } And here’s a great blog post “Crafting a Task.TimeoutAfter Method” (from MS Parallel Library team) with more info on this sort of thing. Addition: at … Read more

The name ‘ConfigurationManager’ does not exist in the current context

It’s not only necessary to use the namespace System.Configuration. You have also to add the reference to the assembly System.Configuration.dll , by Right-click on the References / Dependencies Choose Add Reference Find and add System.Configuration. This will work for sure. Also for the NameValueCollection you have to write: using System.Collections.Specialized;

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)