private static void InternalNavigate(IMXView fromView, string url, Dictionary <string, string> parameters) { Console.WriteLine("InternalNavigation navigating to: " + url); MXContainer container = Instance; // optimization for the server size, property reference is a hashed lookup // fetch and allocate a viable controller IMXController controller = container.GetController(url, parameters); // Initiate load for the associated controller passing all parameters if (controller != null) { container.OnControllerLoadBegin(controller); container.CancelLoad = false; // synchronize load layer to prevent collisions on web-based targets. lock (container) { // Console.WriteLine("InternalNavigate: Locked"); // if there is no synchronization, don't launch a new thread if (container.ThreadedLoad) { // new thread to execute the Load() method for the layer // new Thread((object args) => // { try { //Dictionary<string, string> parameters = (Dictionary<string, string>)args; container.LoadController(fromView, controller, parameters); } catch (Exception ex) { container.OnControllerLoadFailed(controller, ex); } // // }).Start(parameters); } else { try { container.LoadController(fromView, controller, parameters); } catch (Exception ex) { container.OnControllerLoadFailed(controller, ex); } } // Console.WriteLine("InternalNavigate: Unlocking"); } } }
static void TryLoadController(MXContainer container, IMXView fromView, IMXController controller, Dictionary <string, string> parameters) { try { container.LoadController(fromView, controller, parameters); } catch (Exception ex) { container.OnControllerLoadFailed(controller, ex); } }
static void TryLoadController(MXContainer container, IMXView fromView, IMXController controller, Dictionary <string, object> parameters) { try { NSObject nso = new NSObject(); nso.InvokeOnMainThread(() => { container.LoadController(fromView, controller, parameters); }); } catch (Exception ex) { container.OnControllerLoadFailed(controller, ex); } }
/// <summary> /// Tries to execute the Load method of the specified controller using eventing. /// </summary> /// <param name="container">The container that loads the controller.</param> /// <param name="fromView">The view that activated the navigation.</param> /// <param name="controller">The controller to load.</param> /// <param name="navigatedUri">A <see cref="String"/> that represents the uri used to navigate to the controller.</param> /// <param name="parameters">The parameters to use with the controller's Load method.</param> protected static void TryLoadController(MXContainer container, IMXView fromView, IMXController controller, string navigatedUri, Dictionary <string, string> parameters) { // set last navigation container.LastNavigationDate = DateTime.Now; container.LastNavigationUrl = navigatedUri; container.OnControllerLoadBegin(controller, fromView); container.CancelLoad = false; // synchronize load layer to prevent collisions on web-based targets. lock (container) { // Console.WriteLine("InternalNavigate: Locked"); Action <object> load = (o) => { try { container.LoadController(fromView, controller, navigatedUri, parameters); } catch (Exception ex) { container.OnControllerLoadFailed(controller, ex); } }; // if there is no synchronization, don't launch a new thread if (container.ThreadedLoad) { #if NETCF // new thread to execute the Load() method for the layer System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(load)); #else System.Threading.Tasks.Task.Factory.StartNew(() => load(null)); #endif } else { load(null); } // Console.WriteLine("InternalNavigate: Unlocking"); } }
/// <summary> /// Tries to execute the Load method of the specified controller using eventing. /// </summary> /// <param name="container">The container that loads the controller.</param> /// <param name="fromView">The view that activated the navigation.</param> /// <param name="controller">The controller to load.</param> /// <param name="navigatedUri">A <see cref="String"/> that represents the uri used to navigate to the controller.</param> /// <param name="parameters">The parameters to use with the controller's Load method.</param> protected static void TryLoadController(MXContainer container, IMXView fromView, IMXController controller, string navigatedUri, Dictionary <string, string> parameters) { // set last navigation container.LastNavigationDate = DateTime.Now; container.LastNavigationUrl = navigatedUri; container.OnControllerLoadBegin(controller, fromView); container.CancelLoad = false; // synchronize load layer to prevent collisions on web-based targets. lock (container) { // Console.WriteLine("InternalNavigate: Locked"); Action load = () => { try { container.LoadController(fromView, controller, navigatedUri, parameters); } catch (Exception ex) { container.OnControllerLoadFailed(controller, ex); } }; // if there is no synchronization, don't launch a new thread if (container.ThreadedLoad) { // new thread to execute the Load() method for the layer Device.Thread.QueueWorker(a => load()); } else { load(); } // Console.WriteLine("InternalNavigate: Unlocking"); } }