private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { int progress = 0; int totalCount = _datCacheEntities.Count(); BackgroundWorker bgw = (BackgroundWorker)sender; for (int i = 0; i < totalCount; i++) { DatCacheEntity datCacheEntity = _datCacheEntities.ElementAt(i); RearchiveStarted(datCacheEntity); progress = (int)((float)i / (float)totalCount * 100); OverallProgressChanged(progress, string.Format("{0}/{1}", i, totalCount)); if (bgw.CancellationPending) { e.Cancel = true; return; } _sevenZipProcessor = new SevenZipProcessor(); _sevenZipProcessor.OnExceptionOccured += _sevenZipProcessor_OnExceptionOccured; _sevenZipProcessor.OnProgressChanged += _sevenZipProcessor_OnProgressChanged; _sevenZipProcessor.OnCompleted += _sevenZipProcessor_OnCompleted; IProcessInfo decomprocessInfo = new DecompressInfo(datCacheEntity.FilePath, ConfigReader.Instance.WorkingDirectory); _sevenZipProcessor.Run(decomprocessInfo); string extractedFilePath = Path.Combine(ConfigReader.Instance.WorkingDirectory, datCacheEntity.FilenameInArchive); if (bgw.CancellationPending) { e.Cancel = true; return; } _sevenZipProcessor = new SevenZipProcessor(); _sevenZipProcessor.OnExceptionOccured += _sevenZipProcessor_OnExceptionOccured; _sevenZipProcessor.OnProgressChanged += _sevenZipProcessor_OnProgressChanged; _sevenZipProcessor.OnCompleted += _sevenZipProcessor_OnCompleted; IProcessInfo compressInfo = new CompressInfo(extractedFilePath, datCacheEntity.FilePath, ConfigReader.Instance.WorkingDirectory); _sevenZipProcessor.Run(compressInfo); if (bgw.CancellationPending) { e.Cancel = true; return; } datCacheEntity.IsArchived = true; datCacheEntity.IsAltered = false; RearchiveCompleted(datCacheEntity); } RearchiveOverallCompleted(); }
/// <summary> /// Same as <see cref="c_APEDecompress_GetInfo"/>, but used /// in the case where you don't care about the params and want it as an int. /// </summary> /// <param name="handle">The handle to the current decompresser instance.</param> /// <param name="field">The info to get.</param> /// <param name="param1">Generic parameter - usage is listed in <see cref="DecompressInfo"/></param> /// <param name="param2">Generic parameter - usage is listed in <see cref="DecompressInfo"/></param> /// <returns>Int representing whatever info is requested from <see cref="DecompressInfo"/></returns> public static int Decompress_GetInfoInt(IntPtr handle, DecompressInfo field, int param1, int param2) { return c_APEDecompress_GetInfo(handle, field, param1, param2).ToInt32(); }
/// <summary> /// Same as <see cref="c_APEDecompress_GetInfo"/>, but used /// in the case where you don't care about the params and want it as an int. /// </summary> /// <param name="handle">The handle to the current decompresser instance.</param> /// <param name="field">The info to get.</param> /// <returns>Int representing whatever info is requested from <see cref="DecompressInfo"/></returns> public static int Decompress_GetInfoInt(IntPtr handle, DecompressInfo field) { return c_APEDecompress_GetInfo(handle, field, 0, 0).ToInt32(); }
/// <summary> /// Get information about the APE file or the state of the decompressor. /// </summary> /// <param name="handle">Handle to the current decompressor.</param> /// <param name="field">The field we're querying (see APE_DECOMPRESS_FIELDS above for more info)</param> /// <param name="nParam1">Generic parameter - usage is listed in <see cref="DecompressInfo"/></param> /// <param name="nParam2">Generic parameter - usage is listed in <see cref="DecompressInfo"/></param> /// <returns>IntPtr to the retrieved info.</returns> public static IntPtr c_APEDecompress_GetInfo(IntPtr handle, DecompressInfo field, int nParam1, int nParam2) { return Environment.Is64BitProcess ? ApeNative64.c_APEDecompress_GetInfo(handle, field, nParam1, nParam2) : ApeNative32.c_APEDecompress_GetInfo(handle, field, nParam1, nParam2); }
public static extern IntPtr c_APEDecompress_GetInfo(IntPtr handle, DecompressInfo field, int nParam1, int nParam2);
/// <summary> /// Same as <see cref="c_APEDecompress_GetInfo"/>, but used /// in the case where you don't care about the params and want it as an int. /// </summary> /// <param name="handle">The handle to the current decompresser instance.</param> /// <param name="field">The info to get.</param> /// <param name="param1">Generic parameter - usage is listed in <see cref="DecompressInfo"/></param> /// <param name="param2">Generic parameter - usage is listed in <see cref="DecompressInfo"/></param> /// <returns>Int representing whatever info is requested from <see cref="DecompressInfo"/></returns> public static int Decompress_GetInfoInt(IntPtr handle, DecompressInfo field, int param1, int param2) { return(c_APEDecompress_GetInfo(handle, field, param1, param2).ToInt32()); }
/// <summary> /// Same as <see cref="c_APEDecompress_GetInfo"/>, but used /// in the case where you don't care about the params and want it as an int. /// </summary> /// <param name="handle">The handle to the current decompresser instance.</param> /// <param name="field">The info to get.</param> /// <returns>Int representing whatever info is requested from <see cref="DecompressInfo"/></returns> public static int Decompress_GetInfoInt(IntPtr handle, DecompressInfo field) { return(c_APEDecompress_GetInfo(handle, field, 0, 0).ToInt32()); }