High DPI Improvements for Windows Forms in .NET 4.5.2
As part of recently released .NET 4.5.2, Windows Forms is seeing some improvements for its high DPI support. Concern over newer High DPI devices was in the forefront of the April’s Build conference. The need for this update is especially pressing now that Windows 8.1 supports a maximum scaling factor of 250%.
Here is a WinForms application running on .NET 4.5.1 with a high DPI display.
And here is the same application running on .NET 4.5.2.
To enable this feature, add a new <appSettings> element to the configuration file (app.config) and set the EnableWindowsFormsHighDpiAutoResizing element to true:
ASP.NET is getting new APIs for working with background threads under IIS. Previously it was considered a bad practice to run tasks in the background because IIS could terminate the worker process at any time. The new HostingEnvironment.QueueBackgroundWorkItem method will ensure that IIS waits for these background tasks to complete. According to Microsoft, “These will enable ASP.NET applications to reliably schedule Async work items.”
Another set of APIs for ASP.NET allow better control over the HTTP headers.
New HttpResponse.AddOnSendingHeaders and HttpResponseBase.AddOnSendingHeaders methods are more reliable and efficient than HttpApplication.PreSendRequestContent and HttpApplication.PreSendRequestHeaders. These APIs let you inspect and modify response headers and status codes as the HTTP response is being flushed to the client application. These reliability improvements minimize deadlocks and crashes between IIS and ASP.NET.
New HttpResponse.HeadersWritten and HttpResponseBase.HeadersWritten properties that return Boolean values to indicate whether the response headers have been written. You can use these properties to make sure that calls to APIs such as HttpResponse.StatusCode succeeds. This enables shared hosting scenarios for ASP.NET applications.
The next feature concerns MSDTC. This service provides applications with a way to support transactions that span multiple processes or even multiple machines.
[The] distributed transactions enhancement enables promotion of local transactions to Microsoft Distributed Transaction Coordinator (MSDTC) transactions without the use of another application domain or unmanaged code. This has a significant positive impact on the performance of distributed transactions.
A new set of profiling APIs are also being released with .NET 4.5.2:
- COR_PRF_ASSEMBLY_REFERENCE_INFO Structure
- COR_PRF_HIGH_MONITOR Enumeration
- ICorProfilerCallback6::GetAssemblyReferences Method
- ICorProfilerInfo5::GetEventMask2 Method
- ICorProfilerInfo5::SetEventMask2 Method
- ICorProfilerAssemblyReferenceProvider::AddAssemblyReference Method