protected override void BgWorker_DoWork(object sender, DoWorkEventArgs e) { var(ok, filePath) = ExplorerFile.GetCurrentFilePath(); if (ok && !(sender as BackgroundWorker).CancellationPending) { e.Result = filePath; } else { e.Cancel = true; } }
void PopulateFiles(IEnumerable <MyFile> files) { foreach (var file in files) { if (!showHidden && file.hidden) { continue; } ExplorerFile newFile = null; switch (file) { case ImageFile f: newFile = Instantiate(filePrefabImage, filesContainer.transform); break; case VideoFile f: newFile = Instantiate(filePrefabVideo, filesContainer.transform); break; case ARFile f: newFile = Instantiate(filePrefabAR, filesContainer.transform); break; case TextFile f: newFile = Instantiate(filePrefabText, filesContainer.transform); break; case GameFile f: newFile = Instantiate(filePrefabGame, filesContainer.transform); break; } newFile.file = file; newFile.onPointerClick += () => OpenFile(newFile.file); } if (selectedFile != null) { SelectItemInList(selectedFile, GetFilesInContainer()); } }
private void LoopShowFile() { while (isLoop.getValue()) { var(ok, filePath) = ExplorerFile.GetCurrentFilePath(); if (filePath.Contains(desktopPath) && !isLastDesktop) { continue; } if (ok) { dispatcher.Invoke(() => { if (isLoop.getValue()) { OnReceiveFile(filePath, false); } }); } Thread.Sleep(400); } }