Version: 2022.3
言語: 日本語
public Unity.Jobs.JobHandle Close (Unity.Jobs.JobHandle dependency);

パラメーター

dependency (Optional) The JobHandle to wait on before closing the file.

戻り値

JobHandle The JobHandle for the asynchronous close operation. You can use this JobHandle as a dependency when scheduling other jobs that must not run before the close operation is finished.

説明

Asynchronously closes the file referenced by this FileHandle and disposes the FileHandle instance.

Always close FileHandles when done to avoid memory leaks and needlessly locking files. FileHandles that fail to open must still be closed.

Once closed, the FileHandle instance is disposed and becomes invalid. To check for completion of the close operation, use the JobHandle returned by this method.

using System.IO;
using Unity.IO.LowLevel.Unsafe;
using Unity.Jobs;
using UnityEngine;

class AsyncCloseSample : MonoBehaviour { FileHandle fileHandle; public unsafe void Start() { string filePath = Path.Combine(Application.streamingAssetsPath, "myfile.bin");

fileHandle = AsyncReadManager.OpenFileAsync(filePath); }

public unsafe void Update() { if (fileHandle.IsValid() && fileHandle.JobHandle.IsCompleted) { JobHandle closeHandle = fileHandle.Close();

closeHandle.Complete(); } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961