コード例 #1
0
        private void SaveFileWork(object sender, DoWorkEventArgs e)
        {
            FileSaveJob job    = (FileSaveJob)e.Argument;
            var         worker = (BackgroundWorker)sender;

            while (!job.complete)
            {
                Thread.Sleep(0);

                int progress = job.DoWork();

                worker.ReportProgress(progress);
            }
        }
コード例 #2
0
        private void saveFileDialog_FileOk(object sender, CancelEventArgs e)
        {
            RecordingButton.Enabled = false;
            if (e.Cancel)
            {
                return;
            }

            if (!FileSaverBackground.IsBusy)
            {
                var task = new FileSaveJob(VIDEOFILECACHE, AUDIOFILECACHE, saveVideoRecording.FileName);
                FileSaverBackground.RunWorkerAsync(task);
            }
        }
コード例 #3
0
ファイル: FileManager.cs プロジェクト: kamfel/XNotepad
        private async Task SaveDocumentInternal(DocumentInfo docInfo, string filepath)
        {
            if (docInfo.Filepath == null && filepath == null)
            {
                throw new InvalidOperationException($"No filepath specified. DocId: {docInfo.Id}");
            }

            using (var reader = docInfo.Document.CreateReader())
            {
                var targetFilePath = filepath ?? docInfo.Filepath;
                var job            = new FileSaveJob(targetFilePath, reader, docInfo.Encoding);
                var token          = new CancellationToken();
                await JobRunner.Run(job, token);

                docInfo.Hash = job.SavedFileHash;
            }

            if (filepath != null && docInfo.Filepath != filepath)
            {
                docInfo.Filepath = filepath;
            }
        }