Run() public static method

public static Run ( object methodClass, string methodName ) : void
methodClass object
methodName string
return void
Exemplo n.º 1
0
    private void PurchaseThread(object State)
    {
        Hashtable song = (Hashtable)State;

        try
        {
            RunOnMainThread.Run(this, "DoStatusbarUpdate",
                                new object[] { cidProgress, "Purchasing", 2 });

            ArrayList songs = Store.Buy(song);

            RunOnMainThread.Run(this, "DoStatusbarUpdate",
                                new object[] { cidProgress, null, 1 });

            RunOnMainThread.Run(this, "DoStatusbarBalanceUpdate",
                                new object[] { null });

            ThreadPool.QueueUserWorkItem(new WaitCallback(DownloadThread),
                                         songs);
        }
        catch (Exception e)
        {
            RunOnMainThread.Run(this, "DoAlertBox",
                                new object[] { AlertType.Error, e.Message });
        }
    }
Exemplo n.º 2
0
    private void OnPreview(object o, EventArgs args)
    {
        TreeIter      iter;
        TreeModel     model;
        TreeSelection sel = songtv.Selection;

        if (sel.GetSelected(out model, out iter))
        {
            int       index = (int)model.GetValue(iter, 5);
            Hashtable song  = (Hashtable)songs[index];
            if (song["metaData"] != null)
            {
                song = (Hashtable)song["metaData"];
            }
            try
            {
                if (vlc == null)
                {
                    vlc = new VLC();
                }
                if (vlc.IsPlaying)
                {
                    vlc.Stop();
                }
                vlc.ClearPlaylist();
                vlc.AddTarget((string)song["previewURL"]);
                vlc.Play();
            }
            catch (Exception e)
            {
                RunOnMainThread.Run(this, "DoAlertBox",
                                    new object[] { AlertType.Error, e.Message });
            }
        }
    }
Exemplo n.º 3
0
 // Add to body text.
 public void AddBodyText(string text)
 {
     RunOnMainThread.Run(() => {
         bodyText += text;
         Repaint();
     });
 }
Exemplo n.º 4
0
        /// <summary>
        /// Execute the next queued test case.
        /// </summary>
        private static void ExecuteNextTestCase()
        {
            bool executeNext;

            do
            {
                executeNext = false;
                UnityEngine.Debug.Log(String.Format("Remaining test cases {0}", testCases.Count));
                if (testCases.Count > 0)
                {
                    var testCase = testCases[0];
                    testCases.RemoveAt(0);
                    UnityEngine.Debug.Log(String.Format("Test {0} starting...", testCase.Name));
                    // If the test threw an exception on this thread, execute the next test case
                    // in a loop.
                    executeNext = !ExecuteTestCase(
                        testCase,
                        () => {
                        testCase.Method(testCase, (testCaseResult) => {
                            UnityEngine.Debug.Log(String.Format("Test {0} complete",
                                                                testCase.Name));
                            testCaseResult.TestCaseName = testCase.Name;
                            LogTestCaseResult(testCaseResult);
                            RunOnMainThread.Run(() => { ExecuteNextTestCase(); });
                        });
                    }, false);
                }
                else
                {
                    LogSummaryAndExit();
                }
            } while (executeNext);
        }
Exemplo n.º 5
0
    private void SignupThread(object State)
    {
        try
        {
            Hashtable form;

            if (State == null)
            {
                form = Store.Signup();
            }
            else
            {
                form = (Hashtable)State;
                form = Store.SignupStep(form);
            }

            RunOnMainThread.Run(this, "OnSignupEvent",
                                new object[] { form });
        }
        catch (Exception e)
        {
            RunOnMainThread.Run(this, "DoAlertBox",
                                new object[] { AlertType.Error, e.Message });
        }
    }
Exemplo n.º 6
0
    private void DoProgressUpdate(int pos, int total)
    {
        string strProgress = String.Format("Downloaded {0}/{1} bytes",
                                           pos, total);

        RunOnMainThread.Run(this, "DoStatusbarUpdate",
                            new object[] { cidProgress, strProgress, 3 });
    }
Exemplo n.º 7
0
 /// <summary>
 /// Called when the Version Handler has enabled all managed plugins in a project.
 /// </summary>
 public static void VersionHandlerReady()
 {
     UnityEngine.Debug.Log("VersionHandler is ready.");
     Google.VersionHandler.UpdateCompleteMethods = null;
     // Start executing tests.
     ConfigureTestCases();
     RunOnMainThread.Run(() => { ExecuteNextTestCase(); }, runNow: false);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Called when the currently executing command completes.
 /// </summary>
 public void CommandLineToolCompletion(CommandLine.Result result)
 {
     logger.Log(
         String.Format("Command completed: {0}", result.message),
         level: LogLevel.Verbose);
     this.result = result;
     if (ExecutionEnvironment.InBatchMode)
     {
         RunOnMainThread.Run(() => { SignalComplete(); });
     }
 }
Exemplo n.º 9
0
 private void PendingSongsThread(object State)
 {
     try
     {
         songs = Store.PendingSongs();
         RunOnMainThread.Run(this, "DoTreeViewUpdate",
                             new object[] { null });
     }
     catch (Exception e)
     {
         RunOnMainThread.Run(this, "DoAlertBox",
                             new object[] { AlertType.Error, e.Message });
     }
 }
Exemplo n.º 10
0
    private void PepsiThread(object State)
    {
        string strCode = (string)State;

        try
        {
            Store.RedeemPepsiCap(strCode);
        }
        catch (Exception e)
        {
            RunOnMainThread.Run(this, "DoAlertBox",
                                new object[] { AlertType.Error, e.Message });
        }
    }
Exemplo n.º 11
0
    private void RemovePendingSongThread(object State)
    {
        Hashtable song = (Hashtable)State;

        try
        {
            Store.SongDownloadDone(song);
        }
        catch (Exception e)
        {
            RunOnMainThread.Run(this, "DoAlertBox",
                                new object[] { AlertType.Error, e.Message });
        }
    }
Exemplo n.º 12
0
    private void SearchThread(object State)
    {
        string strTerm = (string)State;

        try
        {
            songs = Store.Search(strTerm);
            RunOnMainThread.Run(this, "DoTreeViewUpdate",
                                new object[] { null });
        }
        catch (Exception e)
        {
            RunOnMainThread.Run(this, "DoAlertBox",
                                new object[] { AlertType.Error, e.Message });
        }
    }
Exemplo n.º 13
0
    private void ViewAlbumThread(object State)
    {
        string strPlaylistId = State.ToString();

        try
        {
            songs = Store.ViewAlbum(strPlaylistId);
            RunOnMainThread.Run(this, "DoTreeViewUpdate",
                                new object[] { null });
        }
        catch (Exception e)
        {
            RunOnMainThread.Run(this, "DoAlertBox",
                                new object[] { AlertType.Error, e.Message });
        }
    }
Exemplo n.º 14
0
    private void GiftCertThread(object State)
    {
        string strCertID = (string)State;

        try
        {
            Store.RedeemGiftCertificate(strCertID);
            RunOnMainThread.Run(this, "DoStatusbarBalanceUpdate",
                                new object[] { null });
        }
        catch (Exception e)
        {
            RunOnMainThread.Run(this, "DoAlertBox",
                                new object[] { AlertType.Error, e.Message });
        }
    }
Exemplo n.º 15
0
    private void LoginThread(object State)
    {
        string [] UserPass = (string [])State;

        try
        {
            Store.Login(UserPass[0], UserPass[1], 0);
            RunOnMainThread.Run(this, "OnLoginStateChanged",
                                new object[] { true });
        }
        catch (Exception e)
        {
            RunOnMainThread.Run(this, "DoAlertBox",
                                new object[] { AlertType.Error, e.Message });
            RunOnMainThread.Run(this, "OnLoginStateChanged",
                                new object[] { false });
        }
    }
Exemplo n.º 16
0
        public static void RunAsync(string toolPath, string arguments, CommandLine.CompletionHandler completionDelegate, string workingDirectory = null, Dictionary <string, string> envVars = null, CommandLine.IOHandler ioHandler = null)
        {
            Action action = delegate
            {
                CommandLine.Result result = CommandLine.Run(toolPath, arguments, workingDirectory, envVars, ioHandler);
                RunOnMainThread.Run(delegate
                {
                    completionDelegate(result);
                }, true);
            };

            if (ExecutionEnvironment.InBatchMode)
            {
                RunOnMainThread.Run(action, true);
            }
            else
            {
                Thread thread = new Thread(new ThreadStart(action.Invoke));
                thread.Start();
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Asynchronously execute a command line tool, calling the specified delegate on
        /// completion.
        /// NOTE: In batch mode this will be executed synchronously.
        /// </summary>
        /// <param name="toolPath">Tool to execute.</param>
        /// <param name="arguments">String to pass to the tools' command line.</param>
        /// <param name="completionDelegate">Called when the tool completes.  This is always
        /// called from the main thread.</param>
        /// <param name="workingDirectory">Directory to execute the tool from.</param>
        /// <param name="envVars">Additional environment variables to set for the command.</param>
        /// <param name="ioHandler">Allows a caller to provide interactive input and also handle
        /// both output and error streams from a single delegate.</param>
        public static void RunAsync(
            string toolPath, string arguments, CompletionHandler completionDelegate,
            string workingDirectory             = null,
            Dictionary <string, string> envVars = null,
            IOHandler ioHandler = null)
        {
            Action action = () => {
                Result result = Run(toolPath, arguments, workingDirectory, envVars: envVars,
                                    ioHandler: ioHandler);
                RunOnMainThread.Run(() => { completionDelegate(result); });
            };

            if (ExecutionEnvironment.InBatchMode)
            {
                RunOnMainThread.Run(action);
            }
            else
            {
                Thread thread = new Thread(new ThreadStart(action));
                thread.Start();
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Execute a function for a test case catching any exceptions and logging the result.
        /// </summary>
        /// <param name="testCase">Object executing this method.</param>
        /// <param name="testCaseAction">Action to execute.</param>
        /// <param name="executeNext">Whether to execute the next test case if the specified action
        /// fails.</param>
        /// <returns>true if the action executed without any exceptions, false otherwise.</returns>
        public static bool ExecuteTestCase(TestCase testCase, Action testCaseAction,
                                           bool executeNext)
        {
            bool succeeded = true;

            try {
                testCaseAction();
            } catch (Exception e) {
                LogTestCaseResult(new TestCaseResult(testCase)
                {
                    ErrorMessages = new List <string> {
                        e.ToString()
                    }
                });
                succeeded = false;
            }
            if (!succeeded && executeNext)
            {
                RunOnMainThread.Run(() => { ExecuteNextTestCase(); });
            }
            return(succeeded);
        }
Exemplo n.º 19
0
    private void DownloadThread(object State)
    {
        ArrayList songs = (ArrayList)State;

        mutex.WaitOne();

        foreach (Hashtable song in songs)
        {
            try
            {
                RunOnMainThread.Run(this, "DoStatusbarUpdate",
                                    new object[] { cidProgress, "Downloading", 2 });

                Hashtable meta;

                byte [] sb = Store.DownloadSong(song,
                                                new FairStore.Progress(DoProgressUpdate));

                string strFileName;

                string [,] strReps = new string[, ]
                {
                    { "\\", "-" }, { "/", "-" }, { ":", "" },
                    { "*", "" }, { "?", "" }, { "\"", "\'" },
                    { "<", "" }, { ">", "" }, { "|", "" }
                };

                if (song["metaData"] != null)
                {
                    meta = (Hashtable)song["metaData"];
                }
                else if (song["metadata"] != null)
                {
                    meta = (Hashtable)song["metadata"];
                }
                else
                {
                    meta = song;
                }

                strFileName = String.Format("{0} - {1} - {2}.m4a",
                                            meta["playlistArtistName"], meta["playlistName"],
                                            meta["itemName"]);

                for (int i = 0; i < strReps.Length / 2; i++)
                {
                    strFileName = strFileName.Replace(strReps[i, 0],
                                                      strReps[i, 1]);
                }

                string strPath = Path.Combine(strSongDir, strFileName);

                if (!File.Exists(strPath))
                {
                    FileStream fs =
                        new FileStream(strPath, FileMode.CreateNew);
                    BinaryWriter bw = new BinaryWriter(fs);
                    bw.Write(sb);
                    bw.Close();
                    fs.Close();
                }
            }
            catch (Exception e)
            {
                RunOnMainThread.Run(this, "DoAlertBox",
                                    new object[] { AlertType.Error, e.Message });
            }

            RunOnMainThread.Run(this, "DoStatusbarUpdate",
                                new object[] { cidProgress, null, 1 });
        }

        mutex.ReleaseMutex();
    }