Ejemplo n.º 1
0
 /// <summary>
 /// Waits, at most <paramref name="Timeout"/> milliseconds, until object ready for writing.
 /// Each successful call to <see cref="TryBeginWrite"/> must be followed by exactly one call to <see cref="EndWrite"/>.
 /// </summary>
 /// <param name="Timeout">Timeout, in milliseconds.</param>
 public async Task <bool> TryBeginWrite(int Timeout)
 {
     if (await Semaphores.TryBeginWrite(this.name, Timeout))
     {
         this.isWriting = true;
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Waits, at most <paramref name="Timeout"/> milliseconds, until object ready for reading.
 /// Each successful call to <see cref="TryBeginRead"/> must be followed by exactly one call to <see cref="EndRead"/>.
 /// </summary>
 /// <param name="Timeout">Timeout, in milliseconds.</param>
 public async Task <bool> TryBeginRead(int Timeout)
 {
     if (await Semaphores.TryBeginRead(this.name, Timeout))
     {
         this.nrReaders++;
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Ends a reading session of the object.
        /// Must be called once for each call to <see cref="BeginRead"/> or successful call to <see cref="TryBeginRead(int)"/>.
        /// </summary>
        public async Task EndRead()
        {
            await Semaphores.EndRead(this.name);

            this.nrReaders--;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Waits until object ready for reading.
        /// Each call to <see cref="BeginRead"/> must be followed by exactly one call to <see cref="EndRead"/>.
        /// </summary>
        public async Task BeginRead()
        {
            await Semaphores.BeginRead(this.name);

            this.nrReaders++;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Ends a writing session of the object.
        /// Must be called once for each call to <see cref="BeginWrite"/> or successful call to <see cref="TryBeginWrite(int)"/>.
        /// </summary>
        public async Task EndWrite()
        {
            await Semaphores.EndWrite(this.name);

            this.isWriting = false;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Waits until object ready for writing.
        /// Each call to <see cref="BeginWrite"/> must be followed by exactly one call to <see cref="EndWrite"/>.
        /// </summary>
        public async Task BeginWrite()
        {
            await Semaphores.BeginWrite(this.name);

            this.isWriting = true;
        }