private async Task <PPError> MakeDirectoryAsyncCore(MakeDirectoryFlags makeDirectoryFlags, MessageLoop messageLoop = null) { var tcs = new TaskCompletionSource <PPError>(); EventHandler <PPError> handler = (s, e) => { tcs.TrySetResult(e); }; try { HandleMakeDirectory += handler; if (MessageLoop == null && messageLoop == null) { MakeDirectory(makeDirectoryFlags); } else { Action <PPError> action = new Action <PPError>((e) => { var result = (PPError)PPBFileRef.MakeDirectory(this, (int)makeDirectoryFlags, new BlockUntilComplete() ); tcs.TrySetResult(result); } ); InvokeHelper(action, messageLoop); } return(await tcs.Task); } catch (Exception exc) { Console.WriteLine(exc.Message); tcs.SetException(exc); return(PPError.Aborted); } finally { HandleMakeDirectory -= handler; } }
/// <summary> /// MakeDirectory() makes a new directory in the file system according to the /// given <code>makeDirectoryFlags</code>, which is a bit-mask of the /// <code>MakeDirectoryFlags</code> values. It is not valid to make a /// directory in the external file system. /// </summary> /// <param name="makeDirectoryFlags">A bit-mask of the /// <code>MakeDirectoryFlags</code> values.</param> /// <returns>Error code</returns> PPError MakeDirectory(MakeDirectoryFlags makeDirectoryFlags) => (PPError)PPBFileRef.MakeDirectory(this, (int)makeDirectoryFlags, new CompletionCallback(OnMakeDirectory));