HttpClient.GetAsync(…) never returns when using await/async

You are misusing the API. Here’s the situation: in ASP.NET, only one thread can handle a request at a time. You can do some parallel processing if necessary (borrowing additional threads from the thread pool), but only one thread would have the request context (the additional threads do not have the request context). This is … Read more

Most useful NLog configurations [closed]

Some of these fall into the category of general NLog (or logging) tips rather than strictly configuration suggestions. Here are some general logging links from here at SO (you might have seen some or all of these already): log4net vs. Nlog Logging best practices What’s the point of a logging facade? Why do loggers recommend … Read more

Differences between Microsoft .NET 4.0 full Framework and Client Profile

What’s new in .NET Framework 4 Client Profile RTM explains many of the differences: When to use NET4 Client Profile and when to use NET4 Full Framework? NET4 Client Profile: Always target NET4 Client Profile for all your client desktop applications (including Windows Forms and WPF apps). NET4 Full framework: Target NET4 Full only if … Read more

Setting WPF image source in code

After having the same problem as you and doing some reading, I discovered the solution – Pack URIs. I did the following in code: Image finalImage = new Image(); finalImage.Width = 80; … BitmapImage logo = new BitmapImage(); logo.BeginInit(); logo.UriSource = new Uri(“pack://application:,,,/AssemblyName;component/Resources/logo.png”); logo.EndInit(); … finalImage.Source = logo; Or shorter, by using another BitmapImage constructor: … Read more

Synchronously waiting for an async operation, and why does Wait() freeze the program here

The await inside your asynchronous method is trying to come back to the UI thread. Since the UI thread is busy waiting for the entire task to complete, you have a deadlock. Moving the async call to Task.Run() solves the issue. Because the async call is now running on a thread pool thread, it doesn’t … Read more

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