示例#1
0
        void FindPreviousAsyncCallback(IAsyncResult ar)
        {
            ThreadedAsyncResult tar = (ThreadedAsyncResult)ar;

            FindPreviousOperation state = (FindPreviousOperation)tar.AsyncState;

            if (state.Result == FindPreviousOperation.OperationResult.Finished && state.Match == null)
            {
                InformationAlert ia = new InformationAlert(Catalog.GetString("The pattern you requested was not found."), Catalog.GetString("Beginning of file reached."), mainWindow);
                ia.Run();
                ia.Destroy();
            }
        }
示例#2
0
        ///<summary>
        /// Handles operations that will surely produce on result (eg when
        /// no DataView exists).
        ///</summary>
        IAsyncResult HandleProblematicOp(GenericFindOperation op, AsyncCallback ac)
        {
            op.Result = GenericFindOperation.OperationResult.Finished;

            findFinishedEvent.Reset();

            IAsyncResult iar = new ThreadedAsyncResult(op, findFinishedEvent, true);

            if (ac != null)
            {
                ac(iar);
            }

            findFinishedEvent.Set();
            return(iar);
        }
示例#3
0
        void ReplaceAllAsyncCallback(IAsyncResult ar)
        {
            ThreadedAsyncResult tar = (ThreadedAsyncResult)ar;

            ReplaceAllOperation state = (ReplaceAllOperation)tar.AsyncState;

            if (state.Result == ReplaceAllOperation.OperationResult.Finished)
            {
                InformationAlert ia = new InformationAlert("Found and replaced " + state.NumReplaced + " occurences.", "", null);
                ia.Run();
                ia.Destroy();
            }

            this.Sensitive = true;
            this.Visible   = false;
            this.Visible   = true;
        }
示例#4
0
        void FindNextAsyncCallback(IAsyncResult ar)
        {
            ThreadedAsyncResult tar = (ThreadedAsyncResult)ar;

            FindNextOperation state = (FindNextOperation)tar.AsyncState;

            if (state.Result == FindNextOperation.OperationResult.Finished && state.Match == null)
            {
                InformationAlert ia = new InformationAlert("The pattern you requested was not found.", "End of file reached.", null);
                ia.Run();
                ia.Destroy();
            }

            this.Sensitive = true;
            this.Visible   = false;
            this.Visible   = true;
        }
示例#5
0
        ///<summary>
        /// Save the buffer under the same filename, using an asynchronous model
        ///</summary>
        public IAsyncResult BeginSave(ProgressCallback progressCallback, AsyncCallback ac)
        {
            lock (LockObj) {
                if (!fileOperationsAllowed)
                {
                    return(null);
                }

                saveFinishedEvent.Reset();
                userSaveAsyncCallback = ac;

                Thread saveThread       = null;
                ThreadedAsyncResult tar = null;

                // decide whether to save in place or normally
                if (!fileBuf.IsResizable || this.Size == fileBuf.Size)
                {
                    SaveInPlaceOperation sipo = new SaveInPlaceOperation(this, progressCallback, SaveInPlaceAsyncCallback, useGLibIdle);
                    saveThread = new Thread(sipo.OperationThread);
                    tar        = new ThreadedAsyncResult(sipo, saveFinishedEvent, false);
                }
                else
                {
                    SaveOperation so = new SaveOperation(this, TempFile.CreateName(tempDir), progressCallback, SaveAsyncCallback, useGLibIdle);
                    saveThread = new Thread(so.OperationThread);
                    tar        = new ThreadedAsyncResult(so, saveFinishedEvent, false);
                }

                // don't allow messing up with the buffer
                // while we are saving
                // ...ReadAllowed is set in SaveOperation
                //this.ReadAllowed=false;
                this.ModifyAllowed         = false;
                this.FileOperationsAllowed = false;

                this.EmitEvents         = false;
                fsw.EnableRaisingEvents = false;

                // start save thread
                saveThread.IsBackground = true;
                saveThread.Start();

                return(tar);
            }
        }