Archive

Posts Tagged ‘threading’

Visual Studio 2010 Beta 2 is out!

October 21st, 2009 No comments

Microsoft has just released VisualStudio 2010 Beta 2 to MSDN Subscribers – aka Rosario.

msn_visual_studio_2010

I’m not sure why they’re going with the ULTIMATE moniker for Visual Studio, I still prefer the VS6 style Standard, Professional, Enterprise. Meh.

  • Microsoft Visual Studio 2010 Ultimate with MSDN
    The comprehensive suite of application lifecycle management tools for software teams to ensure quality results from design to deployment.
  • Microsoft Visual Studio 2010 Premium with MSDN
    A complete toolset for developers to deliver scalable, high quality applications.
  • Microsoft Visual Studio 2010 Professional with MSDN
    The essential tool for professional development tasks to assist developers in implementing their ideas easily. (Note: Visual Studio 2010 Professional will also be available without MSDN subscription)

Some of the more exciting things that are coming with Visual Studio 2010 are documented on MSDN or a better one would be Vikas Goyal’s post and also his .NET 4.0 coverage.. Personally the Parallel extensions are the most exciting bits for me. The new Java 7 work is concentrating heavily on concurrency and its good to see both camps pushing the boundaries.

{lang: 'en-GB'}
Share

InvokeRequired with anonymous delegates for threading in WinForms!

September 12th, 2009 2 comments

Here’s a little cookie from the cookie jar. To quote the legendary Jon Skeet from Threading with Windows Forms:

There are two different ways of invoking a method on the UI thread, one synchronous (Invoke) and one asynchronous (BeginInvoke). They work in much the same way – you specify a delegate and (optionally) some arguments, and a message goes on the queue for the UI thread to process. If you use Invoke, the current thread will block until the delegate has been executed. If you use BeginInvoke, the call will return immediately. If you need to get the return value of a delegate invoked asynchronously, you can use EndInvoke with the IAsyncResult returned by BeginInvoke to wait until the delegate has completed and fetch the return value.

Here’s a simple, uncluttered version you can utilise and reuse – this example just adds a list item to the listview.

        public void Add(ListViewItem item)
        {
            if (m_ListView.InvokeRequired)
            {
                m_ListView.BeginInvoke(new MethodInvoker(() => Add(item)));
            }
            else
            {
                m_ListView.Items.Add(item);
            }
        }

First we check whether we’re executing on the GUI thread or not (InvokeRequired), then execute a delegate thats parsed into the MethodInvoker calling itself using a lambda expression. This code is VS2008 compatible (.NET 2.0 +).

For a non lambda version:

      
        public void Add(ListViewItem item)
        {
            if (m_ListView.InvokeRequired)
            {
                m_ListView.BeginInvoke(new MethodInvoker(delegate
                                                             {
                                                                 Add(item);
                                                             }));
            }
            else
            {
                m_ListView.Items.Add(item);
            }
        }

The advantage of using an anonymous delegate is that by design, delegates are able to use local variables and parameters scoped in the containing method. Therefore we didn’t need to create a custom delegate with the signature to pass onto the method.

{lang: 'en-GB'}
Share

Going Deep: Inside Windows 7 with Mark Russinovich

October 29th, 2008 No comments

If you like discussions about deep internals you’ll most definately have subscribed to the Going Deep series on Channel 9. Today they just released a fascinating interview with Kernel Guru, Mark Russinovich – of Sysinternals fame, who is now a Technical Fellow at Microsoft. One of my favourite books would have to be Windows Internals 4th Edition, and reference it quite frequently. Cant wait for the 5th edition!!!

One very important change in Windows 7 kernel is the dismantling of the Spin Lock Dispatcher and redesign and implementation of its functionality into separate components. This work was done by Arun Kishan (you’ve met him here on C9 last year). The direct result of this great work is that Windows 7 can scale to 256 processors and enabled the great Landy Wang to tune Windows Memory manager to be even more efficient than it already is. Mark also explains (again) what MinWin really is (heck, even I was confused. Not anymore…). MinWin is present in Windows 7.

There are some really interesting topics covered in this video, especially the content behind the scheduler and the thread dispatcher.

Channel 9 Going Deep: Inside Windows 7

Download Offline versions: WMV | WMV HD | MP4 (iPod) | ZUNE

{lang: 'en-GB'}
Share