mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2024-11-10 08:34:12 +01:00
Remove PInvoke.Kernel32
This commit is contained in:
parent
5ac61011c4
commit
f0c9993c6e
3 changed files with 3 additions and 63 deletions
|
@ -1,46 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
using static PInvoke.Kernel32;
|
|
||||||
|
|
||||||
|
|
||||||
namespace FFMpegCore.Extend {
|
|
||||||
public class Job : IDisposable {
|
|
||||||
readonly SafeObjectHandle handle;
|
|
||||||
|
|
||||||
public Job() {
|
|
||||||
this.handle = CreateJobObject(IntPtr.Zero, null);
|
|
||||||
|
|
||||||
var info = new JOBOBJECT_BASIC_LIMIT_INFORMATION {
|
|
||||||
LimitFlags = JOB_OBJECT_LIMIT_FLAGS.JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE,
|
|
||||||
};
|
|
||||||
|
|
||||||
var extendedInfo = new JOBOBJECT_EXTENDED_LIMIT_INFORMATION { BasicLimitInformation = info };
|
|
||||||
|
|
||||||
int length = Marshal.SizeOf(typeof(JOBOBJECT_EXTENDED_LIMIT_INFORMATION));
|
|
||||||
IntPtr extendedInfoPtr = Marshal.AllocHGlobal(length);
|
|
||||||
Marshal.StructureToPtr(extendedInfo, extendedInfoPtr, false);
|
|
||||||
|
|
||||||
if (!SetInformationJobObject(this.handle, JOBOBJECTINFOCLASS.JobObjectExtendedLimitInformation, extendedInfoPtr, (uint)length))
|
|
||||||
throw new System.ComponentModel.Win32Exception();
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool AddProcess(SafeObjectHandle processHandle) {
|
|
||||||
return AssignProcessToJobObject(this.handle, processHandle);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region IDisposable Members
|
|
||||||
|
|
||||||
public void Dispose() {
|
|
||||||
this.Dispose(true);
|
|
||||||
GC.SuppressFinalize(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void Dispose(bool disposing) => this.Close();
|
|
||||||
|
|
||||||
public void Close() => this.handle.Close();
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -9,12 +9,6 @@
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using FFMpegCore.Enums;
|
using FFMpegCore.Enums;
|
||||||
using FFMpegCore.Exceptions;
|
|
||||||
using FFMpegCore.Extend;
|
|
||||||
using FFMpegCore.Helpers;
|
|
||||||
using Instances;
|
|
||||||
|
|
||||||
using PInvoke;
|
|
||||||
|
|
||||||
namespace FFMpegCore
|
namespace FFMpegCore
|
||||||
{
|
{
|
||||||
|
@ -148,13 +142,6 @@ private async Task<IProcessResult> Process(ProcessArguments processArguments, Ca
|
||||||
_ffMpegArguments.Pre();
|
_ffMpegArguments.Pre();
|
||||||
|
|
||||||
using var instance = (ProcessInstance)processArguments.Start();
|
using var instance = (ProcessInstance)processArguments.Start();
|
||||||
|
|
||||||
using var job = new Job();
|
|
||||||
var processHack = (Process)typeof(ProcessInstance).GetField("_process", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)
|
|
||||||
.GetValue(instance);
|
|
||||||
using var instanceHandle = new Kernel32.SafeObjectHandle(processHack.Handle, ownsHandle: false);
|
|
||||||
job.AddProcess(instanceHandle);
|
|
||||||
|
|
||||||
var cancelled = false;
|
var cancelled = false;
|
||||||
void OnCancelEvent(object sender, int timeout)
|
void OnCancelEvent(object sender, int timeout)
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,13 +12,12 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\README.md" Pack="true" PackagePath="\"/>
|
<None Include="..\README.md" Pack="true" PackagePath="\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Instances" Version="3.0.0"/>
|
<PackageReference Include="Instances" Version="3.0.0" />
|
||||||
<PackageReference Include="PInvoke.Kernel32" Version="0.7.104" />
|
<PackageReference Include="System.Text.Json" Version="7.0.1" />
|
||||||
<PackageReference Include="System.Text.Json" Version="7.0.1"/>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
Loading…
Reference in a new issue