Exemple #1
0
        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;
            }
        }
Exemple #2
0
 /// <summary>
 /// MakeDirectoryAsync() makes a new directory asynchronously 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>
 /// <param name="messageLoop">Optional MessageLoop instance used to run the command on.</param>
 /// <returns>Error code</returns>
 public Task <PPError> MakeDirectoryAsync(MakeDirectoryFlags makeDirectoryFlags, MessageLoop messageLoop = null)
 => MakeDirectoryAsyncCore(makeDirectoryFlags, messageLoop);
Exemple #3
0
 /// <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));