private static void updateTargetsList(object state)
 {
     lock (locker)
     {
         var  devices       = PortDefinition.Enumerate(PortFilter.Usb);
         var  targetsToKeep = new List <MicroFrameworkExecutionTarget>();
         bool changed       = false;
         foreach (var device in devices)
         {
             bool targetExist = false;
             foreach (var target in targets)
             {
                 if (target.PortDefinition.Port == (device as PortDefinition).Port)
                 {
                     targetsToKeep.Add(target);
                     targetExist = true;
                     break;
                 }
             }
             if (!targetExist)
             {
                 changed = true;
                 var newTarget = new MicroFrameworkExecutionTarget(device as PortDefinition);
                 targets.Add(newTarget);
                 targetsToKeep.Add(newTarget);
             }
         }
         changed |= targets.RemoveAll((target) => !targetsToKeep.Contains(target)) > 0;
         if (changed && deviceListChanged != null)
         {
             deviceListChanged(null);
         }
     }
 }
		private static void updateTargetsList(object state)
		{
			lock(locker)
			{
				var devices = PortDefinition.Enumerate(PortFilter.Usb);
				var targetsToKeep = new List<MicroFrameworkExecutionTarget>();
				bool changed = false;
				foreach(var device in devices)
				{
					bool targetExist = false;
					foreach(var target in targets)
					{
						if(target.PortDefinition.Port == (device as PortDefinition).Port)
						{
							targetsToKeep.Add(target);
							targetExist = true;
							break;
						}
					}
					if(!targetExist)
					{
						changed = true;
						var newTarget = new MicroFrameworkExecutionTarget(device as PortDefinition);
						targets.Add(newTarget);
						targetsToKeep.Add(newTarget);
					}
				}
				changed |= targets.RemoveAll((target) => !targetsToKeep.Contains(target)) > 0;
				if(changed && deviceListChanged != null)
					deviceListChanged(null);
			}
		}