/// <summary>
		/// Runs a method passed in. If UseThreading is true then the method
		/// is run using the DeferredInvoke method otherwise it is run directly.
		/// </summary>
		/// <param name="methodToRun">the method to run</param>
		/// <param name="args">argument to pass to the method</param>
		/// <remarks>
		/// Use this method to call code that must be run on the UI thread. This
		/// method is smart, thus it will detect if it is run from the UI thread
		/// and either run the method on the current thread or marshal it to the
		/// UI thread.
		/// </remarks>
		private void Invoke(DeferredHandler methodToRun, object args)
		{
			if (UseThreading && !Application.IsApplicationThread)
				Application.DeferredInvoke(methodToRun, args, TimeSpan.FromTicks(1));
			else
				methodToRun(args);
		}
		/// <summary>
		/// Runs a method passed in. If UseThreading is true then the method
		/// is run using the DeferredInvoke method otherwise it is run directly.
		/// </summary>
		/// <param name="methodToRun">the method to run</param>
		/// Use this method to call code that must be run on the UI thread. This
		/// method is smart, thus it will detect if it is run from the UI thread
		/// and either run the method on the current thread or marshal it to the
		/// UI thread.
		/// </remarks>
		private void Invoke(DeferredHandler methodToRun)
		{
			Invoke(methodToRun, null);
		}