.NET Task class

Hey! Just to give you a heads up for a new class called Task introduced in .Net Framework 4.

This class, as the name suggests, allows the developer to run a synchronous or asynchronous job in a separate thread. It offers quite a few advantages in comparison with other well known classes like the now old BackgroundWorker like the possibility to cancel a task and the possibility to create sub-tasks and many others. In exchange what you see in BackgroundWorker and you don’t see in Task class is progress reporting. Fortunately this is a functionality that is easily implementable also using a Task class. See this nice post for how to do it. You can also find there an equivalent implementation using BackgroundWorker.

Task class is found inside System.Threading.Tasks namespace. This class and related types are part of a set of public types called TPL (Task Parallel Library) and it is a new programming model introduced by Microsoft in it’s framework mainly for parallel programming.

For more information please visit MSDN page for TPL (Task Parallel Library).

Here’s a simple example (from MSDN) of code showing how you can manipulate a single Task instance:

Read the rest of this entry »

Generate PDF files in Asp .NET

How can you print documents in PDF format from ASP .NET?

If you have to generate reports then maybe Microsoft Reports or Crystal Reports would be better choices. Microsoft Reports comes with Visual Studio. Crystal Reports was included in Visual Studio until VS2008. If you want to use Crystal Reports in Visual Studio 2010 then go here.

For PDF printing there are several solutions out there.

So…here are a few of the products I ‘googled’ upon:

Read the rest of this entry »

Web PI just hangs

So if your Web Platform Installer too just hangs at startup before showing up the list of products to install, maybe you have the same problem I ran into a few minutes ago.
Searching the web the following solutions/diagnostics were proposed:
- look in System and Application system event logger – I couldn’t find anything related
- look in %temp%\webpi_launcher.txt for clues – mine was empty
- look in %USERPROFILE%\AppData\Local\Microsoft\Web Platform Installer for clues – yeap that’s it!

Actually in %USERPROFILE%\AppData\Local\Microsoft\Web Platform Installer\logs there are logs which are created each time your start Web PI. And in those logs I saw that Web PI loads data at startup from a cached files located at %USERPROFILE%\AppData\Local\Microsoft\Web Platform Installer.

Solution: just delete all those files located at %USERPROFILE%\AppData\Local\Microsoft\Web Platform Installer and restart Web PI. It worked in my case.

TextBlock vs Label in WPF

A question that most probably every WPF developer asked himself is why have Label and TextBlock controls in WPF?

Doing a simple google search gave this answer:

Label is a more complex control than TextBlock and it has features like access keys (mnemonics) and target controls. So when you hit Alt-Key than the target control get focus (e.g. a label and a textbox).

This difference resides in the fact that TextBlock, even though it is included in Windows.System.Controls namespace, it is not a control. It inherits FrameworkElement class not the Control class. Label on the other hand it inherits from Control class.

For more details I would suggest a post on “John Smith On WPF” blog:

http://joshsmithonwpf.wordpress.com/2007/07/04/differences-between-label-and-textblock/

Stop a Virtual PC image from synchronizing the date with the host OS

To stop the VPC image from synchronizing, add the following XML section to the .VMC file:

<integration>
  <microsoft>
   ….
   <components>
    <host_time_sync>
     <enabled type="boolean">false</enabled>
    </host_time_sync>
   </components>
   ….
  </microsoft>
</integration>

Follow

Get every new post delivered to your Inbox.