Esempio n. 1
0
        public void InitWithDataTest()
        {
            var obj    = new InitWithDataObject();
            var thread = new NSThread(obj, new Selector("start:"), null);

            thread.Start();
            Assert.IsTrue(obj.StartedEvent.WaitOne(TimeSpan.FromSeconds(5)), "thread start");
            GC.Collect();
        }
Esempio n. 2
0
            public static void InitializeCocoaThreadingLocks()
            {
                var helper = new ThreadHelper();
                var thread = new NSThread(helper, Selector.FromHandle(Selector.GetHandle(InitThreadingName)), new NSObject());

                thread.Start();
                helper._event.WaitOne();
                helper._event.Dispose();
                if (!NSThread.IsMultiThreaded)
                {
                    throw new Exception("Unable to initialize Cocoa threading");
                }
            }
Esempio n. 3
0
    /*
         Tells Appirater that the app was brought to the foreground on multitasking
         devices. You should call this method from the application delegate's
         applicationWillEnterForeground: method.

         If the app has been used enough to be rated (and enough significant events),
         you can suppress the rating alert
         by passing NO for canPromptForRating. The rating alert will simply be postponed
         until it is called again with YES for canPromptForRating. The rating alert
         can also be triggered by appLaunched: and userDidSignificantEvent:
         (as long as you pass YES for canPromptForRating in those methods).
         */
    public void AppEnteredForeground(bool canPromptForRating)
    {
        NSThread t = new NSThread (this, new Selector (SELECTOR_INCREMENT_AND_RATE), NSNumber.FromBoolean (canPromptForRating));
        t.Start ();
    }
Esempio n. 4
0
    /*
         Tells Appirater that the user performed a significant event. A significant
         event is whatever you want it to be. If you're app is used to make VoIP
         calls, then you might want to call this method whenever the user places
         a call. If it's a game, you might want to call this whenever the user
         beats a level boss.

         If the user has performed enough significant events and used the app enough,
         you can suppress the rating alert by passing NO for canPromptForRating. The
         rating alert will simply be postponed until it is called again with YES for
         canPromptForRating. The rating alert can also be triggered by appLaunched:
         and appEnteredForeground: (as long as you pass YES for canPromptForRating
         in those methods).
         */
    public void UserDidSignificantEvent(bool canPromptForRating)
    {
        NSThread t = new NSThread (this, new Selector (SELECTOR_INCREMENT_EVENT_AND_RATE), NSNumber.FromBoolean (canPromptForRating));
        t.Start ();
    }
Esempio n. 5
0
    /*
     *       Tells Appirater that the user performed a significant event. A significant
     *       event is whatever you want it to be. If you're app is used to make VoIP
     *       calls, then you might want to call this method whenever the user places
     *       a call. If it's a game, you might want to call this whenever the user
     *       beats a level boss.
     *
     *       If the user has performed enough significant events and used the app enough,
     *       you can suppress the rating alert by passing NO for canPromptForRating. The
     *       rating alert will simply be postponed until it is called again with YES for
     *       canPromptForRating. The rating alert can also be triggered by appLaunched:
     *       and appEnteredForeground: (as long as you pass YES for canPromptForRating
     *       in those methods).
     */
    public void UserDidSignificantEvent(bool canPromptForRating)
    {
        NSThread t = new NSThread(this, new Selector(SELECTOR_INCREMENT_EVENT_AND_RATE), NSNumber.FromBoolean(canPromptForRating));

        t.Start();
    }
Esempio n. 6
0
    /*
     *       Tells Appirater that the app was brought to the foreground on multitasking
     *       devices. You should call this method from the application delegate's
     *       applicationWillEnterForeground: method.
     *
     *       If the app has been used enough to be rated (and enough significant events),
     *       you can suppress the rating alert
     *       by passing NO for canPromptForRating. The rating alert will simply be postponed
     *       until it is called again with YES for canPromptForRating. The rating alert
     *       can also be triggered by appLaunched: and userDidSignificantEvent:
     *       (as long as you pass YES for canPromptForRating in those methods).
     */
    public void AppEnteredForeground(bool canPromptForRating)
    {
        NSThread t = new NSThread(this, new Selector(SELECTOR_INCREMENT_AND_RATE), NSNumber.FromBoolean(canPromptForRating));

        t.Start();
    }
Esempio n. 7
0
        private void procBtn(int state = 1)
        {
            if (state == 4)
            {
                string[]    filetypes = { "rar" };
                NSOpenPanel dlg       = NSOpenPanel.OpenPanel;
                dlg.Title                   = "Selecione";
                dlg.CanChooseFiles          = true;
                dlg.CanChooseDirectories    = false;
                dlg.AllowedFileTypes        = filetypes;
                dlg.AllowsMultipleSelection = false;
                dlg.ResolvesAliases         = true;
                dlg.ReleasedWhenClosed      = true;
                dlg.BeginSheet(this, (i) => {
                    try
                    {
                        if (dlg.Url != null)
                        {
                            var urlString = dlg.Url.Path;
                            if (!string.IsNullOrEmpty(urlString))
                            {
                                //NSDate DateLoop = new NSDate ();
                                //DateLoop = DateLoop.AddSeconds (0.1);
                                //NSRunLoop.Current.RunUntil(DateLoop );

                                NSThread.Start(() => {
                                    clsRAR orar = new clsRAR();
                                    rarFile     = orar.OpenRAR(urlString, this, this.tbv_Arquivos);
                                    orar        = null;
                                });
                            }
                        }
                    }
                    finally
                    {
                        dlg.Dispose();
                        dlg = null;
                    }
                });
            }
            else
            {
                NSIndexSet nSelRows = this.tbv_Arquivos.SelectedRows;
                if (nSelRows.Count > 0)
                {
                    nuint[] nRows = nSelRows.ToArray();
                    if (nRows.Length > 0)
                    {
                        ViewArquivosDataSource datasource = (ViewArquivosDataSource)this.tbv_Arquivos.DataSource;
                        clsViewArquivos        cvarqs     = new clsViewArquivos();
                        string aState = string.Empty;
                        foreach (nint lRow in nRows)
                        {
                            switch (state)
                            {
                            case 1:
                                aState = "1";
                                break;

                            case 2:
                                aState = cvarqs.GetTagsArquivo(datasource, (int)lRow, 1);
                                break;

                            case 3:
                                NSOpenPanel dlg = NSOpenPanel.OpenPanel;
                                dlg.Title                   = "Salvar em";
                                dlg.CanChooseFiles          = false;
                                dlg.CanChooseDirectories    = true;
                                dlg.AllowsMultipleSelection = false;
                                dlg.ResolvesAliases         = true;
                                dlg.ReleasedWhenClosed      = true;
                                dlg.BeginSheet(this, (i) => {
                                    try {
                                        string urlString = dlg.Url.Path;
                                        if (!string.IsNullOrEmpty(urlString))
                                        {
                                            nSelRows = this.tbv_Arquivos.SelectedRows;
                                            NSThread.Start(() => {
                                                clsRAR exRAR = new clsRAR();
                                                exRAR.ExtractRAR(this, this.tbv_Arquivos, nSelRows, rarFile, urlString);
                                                exRAR = null;
                                            });
                                        }
                                    } finally {
                                        dlg.Dispose();
                                        dlg = null;
                                    }
                                    this.tbv_Arquivos.ReloadData();
                                });
                                break;

                            case 5:

                                break;
                            }
                            if (state != 3)
                            {
                                cvarqs.SetTagsArquivo(datasource, (int)lRow, aState);
                                cvarqs     = null;
                                datasource = null;
                                this.tbv_Arquivos.ReloadData();
                            }
                        }
                    }
                }
                else
                {
                    string mText = string.Empty;
                    string iText = string.Empty;
                    switch (state)
                    {
                    case 1:
                        mText = "Remover Arquivo(s)";
                        iText = "Selecione ao menos um aquivo para Remover !";
                        break;

                    case 2:
                        mText = "Desfazer Ação";
                        iText = "Selecione ao menos um arquivo para\r\n Desfazer a Ação !";
                        break;

                    case 3:
                        mText = "Extrair Arquivos";
                        iText = "Selecione ao menos um arquivo para Extrair !";
                        break;
                    }

                    NSAlert alert = new NSAlert()
                    {
                        AlertStyle      = NSAlertStyle.Warning,
                        InformativeText = iText,
                        MessageText     = mText,
                    };
                    alert.RunSheetModal(this);
                }
            }
        }