internal static void __AfterElementLoaded(__InternalElementProxy that, Action e)
        {
            if (that.__IsElementLoaded)
            {
                e();
                return;
            }

            that.__Delayed.Add(e);
        }
        internal static void __DelayedInvoke(__InternalElementProxy that)
        {
            // after jsc.meta rewrites this method, jsc cannot handle OpCodes.Leave if it does not return...
            // todo: we should create a new test project and fix it!
            foreach (var item in that.__Delayed)
            {
                //Native.Window.alert("__DelayedInvoke ##");

                item();
            }
        }
		internal static void __DelayedInvoke(__InternalElementProxy that)
		{

			// after jsc.meta rewrites this method, jsc cannot handle OpCodes.Leave if it does not return...
			// todo: we should create a new test project and fix it!
			foreach (var item in that.__Delayed)
			{
				//Native.Window.alert("__DelayedInvoke ##");

				item();
			}
		}
		internal static string __ExportDelegate(__InternalElementProxy that, Delegate value, string method)
		{
			if (that.__ExportDelegateContext == null)
				that.__ExportDelegateContext = new __ExportDelegateContextType();

			var __callback = that.__ExportDelegateContext.GenerateName(method);

			IFunction.OfDelegate(value).Export(__callback);

			return __callback;

		}
        internal static string __ExportDelegate(__InternalElementProxy that, Delegate value, string method)
        {
            if (that.__ExportDelegateContext == null)
            {
                that.__ExportDelegateContext = new __ExportDelegateContextType();
            }

            var __callback = that.__ExportDelegateContext.GenerateName(method);

            IFunction.OfDelegate(value).Export(__callback);

            return(__callback);
        }
        internal static void __SetElementLoaded(__InternalElementProxy that)
        {
            //Native.Window.alert("__SetElementLoaded");

            //new ScriptCoreLib.JavaScript.Runtime.Timer(
            //    t =>
            {
                that.__IsElementLoaded = true;
                __DelayedInvoke(that);
                //Native.Window.alert("__DelayedInvoke");
                that.__Delayed.Clear();
                //t.Stop();
            }

            // chrome needs some extra time?
            //, 100, 100);
        }
		internal static void __SetElementLoaded(__InternalElementProxy that)
		{
			//Native.Window.alert("__SetElementLoaded");

			//new ScriptCoreLib.JavaScript.Runtime.Timer(
			//    t =>
			{
				that.__IsElementLoaded = true;
				__DelayedInvoke(that);
				//Native.Window.alert("__DelayedInvoke");
				that.__Delayed.Clear();
				//t.Stop();
			}

			// chrome needs some extra time?
			//, 100, 100);
		}
		internal static void __AfterElementLoaded(__InternalElementProxy that, Action e)
		{
			if (that.__IsElementLoaded)
			{
				e();
				return;
			}

			that.__Delayed.Add(e);
		}