Friday, December 28, 2012

Linux on Windows 8

Yes, you heard me right, Linux on Windows 8.  Why would you do that?  Simple, Windows 8 Pro supports Hyper-V (on SLAT supported architectures), and provides a fantastic tool for your virtual machine needs.

Before jumping into Hyper-V, you will want to make sure you have a system which will support it.  Here are a few links to help.
http://blogs.msdn.com/b/taylorb/archive/2008/06/19/hyper-v-will-my-computer-run-hyper-v-detecting-intel-vt-and-amd-v.aspx

64-bit Windows 8 Pro supports Hyper-V and after you install it, you will need to enable Hyper-V.  This is done using the control panel, selecting programs, then choosing Turn Windows Features on or off


From Windows Features, a dialog will present you will a number of options.  If your system supports hyper-v, then it will be available for you to enable.


The hyper-v manager should now be accessible from the start screen.


Now, the fun can begin!   Launching the manager will give you access to create VMs.  This is very cool and, as I mentioned,  is part of the Windows 8 Pro operating system.  You don't have to install any 3rd party software packages or costly virtual machine emulators.  The screen shot, below, is from my Dell laptop running Win8.  I have three VMs installed and the highlighted one is the Linux OS, CentOS.



It is very easy to create your own VM and Microsoft has done an excellent job providing a wizard approach to configuration.  This blog entry just  highlights the hyper-v feature and more details may follow with another blog entry.  

But wait, there's more!

Before I wrap this up, I do want to bring to your attention another fantastic feature of Windows 8.  Once you download the ISO you wish to install, all you have to do is right-click the ISO file, then select Mount.  Mounting ISO files is a feature which is part of Windows 8.  No longer needed are additional applications to help with using ISO files.  Your mounted ISO will show up as a drive letter.

I'll leave you with a final screen shot.  It is from my VM, running CentOS.   Enjoy!

Monday, December 17, 2012

Windows 8 Does Java

This is my Windows 8 start screen.  Look closely at the red highlighted box.  See it?   Yes, your eyes are not deceiving you.  This is, in deed, a tile with Eclipse on it.  64-bit Eclipse, Juno,  downloaded from Eclipse.org.   No modifications were needed.


My laptop is running 64-bit Java, from java.oracle.com, and I have not encountered any issues.  Despite what you might hear, Windows 8 will do Java and makes for a decent development environment.   I plan to post more information pertaining to Java; but, for now, I'll leave you with a screen shot of Eclipse and the obligatory Hello World application and some messages from the command prompt.





















Tuesday, December 11, 2012

Getting Started with Windows Phone 8 Dev.


How to get started developing for Windows Phone 8.

This is a great question and the answer is with mixed feelings.  I say mixed, because mobile development has a few extra hurdles than the previous .netcf way.  On the other side, Windows Phone 8 is a great platform and is in-line with modern XAML application development.

Before you get started, you need a computer running 64-bit Windows 8 Pro.  Sadly, this has to be on bare metal and not running under a VM.   The reason for this has to do with the Emulator.  It requires hyper-v, so your computer must also support  Hyper-V (SLAT) .  When you think about it, having the emulator as a VM is pretty darn cool.

Once you have the basics down, you need to get yourself a copy of Visual Studio 2012.  If you don’t already have VS 2012, you can download a free version of Express.  The links at the bottom will help you find the right version.  Remember you need the version to support Windows 8 Phone.

If you are already running Visual Studio 2012, get the Windows Phone 8 SDK.  The SDK will add all the functionality you need to build Phone applications, which includes the Emulator.  With Win8, you can target Windows Phone 8 and 7.5.

After you have all of this downloaded and installed, and you've built an app running on the emulator, then you will want to take it for a test drive on a real Windows Phone 8 device.   In order to do this, you have to get a developer’s license for the Windows Store.  Oh, and you will need a Windows Phone 8.  I suggest the Nokia 920.

Lastly, you may want some help learning about developing Windows Phone 8 apps.  This link will direct you to the Windows Phone 8 Jump Start:


Links to help you with Hyper-V


Windows 8, Pro
  
Visual Studio 2012

Windows Phone SDK

Developer’s License:

Thursday, December 6, 2012

C# Parallel Tasks (for)


Recently, I’ve been working on a project requiring the need to process very large quantities of data.  Many of the processes we have been writing can be broken up into parallel tasks.   While the .net framework has supported multithreading since the beginning, the 4.0 version introduced the System.Threading.Tasks namespace.    This is a nice collection of classes to help make multithreaded programming a bit easier.

Looking at the MSDN documentation

You will see a number of classes.  For this posting, I am going to zero-in on the Parallel class.

Here you will find heavily overloaded methods For and ForEach, both of these are methods to iteratively preform work on a thread.   If you have not looked at this before, it is a very welcome treat!

The first things you will add to your code are the using statements.
using System.Threading;           //  Thread
using System.Threading.Tasks;     // Parallel

The Parallel class is found in System.Threading.Tasks, but you may still want to use Thread, which will require System.Threading.

The basic syntax is this…
Parallel.For(Int32, Int32,Action<Int32>);
Argument 1, starting value (Inclusive)
Argument 2, ending value (Exclusive)
Argument 3, Action to perform

The premise is simple, you iterate just like you would a traditional for loop; however, unlike a traditional for loop, each iteration is performed in its own task (thread).   I'm demonstrating a Parallel.For loop, but there is also a Parallel.ForEach.

Here is a very simple example:

using System;
using System.Threading;
using System.Threading.Tasks;
namespace ParallelSample
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Parallel.For(0, 10, DoThis);
            Console.Read();
        }
        public static void DoThis(int i)
        {
            //try adding a Thread.Sleep(5000);
            Console.WriteLine("*** {0} ThreadID= {1}", i,
Thread.CurrentThread.ManagedThreadId);
        }
    }
}

On the other hand, using lambda expressions, you might code something like this:

using System;
using System.Threading;
using System.Threading.Tasks;

namespace ParallelSample
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Parallel.For(0, 10, i =>
            {
                Console.WriteLine("*** {0} ThreadID= {1}", i, Thread.CurrentThread.ManagedThreadId);
            });
            Console.Read();
        }
    }
}


This is but the very basics of the Parallel For.  The example simply demonstrates how to set your code up for multitasking iteration.  You will still need to follow the general rules for developing multithreaded programs and implement thread safe code where applicable.

One thing I did not mention was the use of the ParallelOptions object.   This object can provide some nifty features to your tasks, such a limiting the degrees of parallelism with the MaxDegreeOfParallelism property.  In the sample, below, I am using this object to limit only three threads of execution at a time.   This can help prevent overloading the server with worker threads.  Observe the overloaded For method.  It takes the ParallelOptions object as an arguement.  

        public static void Main(string[] args)
        {
            var po = new ParallelOptions() { MaxDegreeOfParallelism = 3 };

            Parallel.For(0, 10, po, i =>
                {
                    Console.WriteLine("*** {0} ThreadID= {1}", i,
                        Thread.CurrentThread.ManagedThreadId);
                });

            Console.Read();
        }


Lastly, you may want to take into consideration, the number of processors available.  One way to do this is to do the following:

Console.WriteLine(Environment.ProcessorCount);

When you run the examples, experiment and add additional code.  Perhaps try a Thread.Sleep call and observe the output.   








Monday, December 3, 2012

East Side Developer Group

One of the down-sides to living on the Illinois side of St. Louis is the lack of good technical interest groups.  If you are serious about software development, or just interested in general technology, you will have to make a trek over to the Missouri side.    The issue about going "Across the River" is not the distance or fear of driving over a bridge.  The issue is having to drive 45 minutes to get home.

After a long day at the office, I want to get home, relax, and maybe read about some code.  Going to a monthly SIG is fine, but it is that last hour which makes things so unattractive.   If only there was something on the East Side...so that last hour is not so painful.

I am in the process of securing a very good location, with easy access to the Metro Link, Internet, overhead projection, and decent room accommodations    This work-in-progress will be much easier if I had a good grasp of the number of people who may be interested in a monthly group.

If you are interested in attending, or interested in presenting, shoot me an email.  Microsoft, Java, Open Source...everyone is welcome!  WhatsTheBigIT@outlook.com

I hope to have some specifics in January, 2013.

Pass the word around.