Exemple #1
0
        ///////////////////////////////////////////////////////////////////////

        public static void SetSynchronized(
            Result synchronizedResult,
            ReturnCode code,
            Result result
            )
        {
            //
            // NOTE: Does the caller want to be notified about the result?
            //
            if (synchronizedResult != null)
            {
                lock (synchronizedResult)
                {
                    //
                    // NOTE: Grab the original client data (the event wait
                    //       handle).
                    //
                    IClientData clientData = synchronizedResult.ClientData;

                    //
                    // NOTE: Set the new client data (the result pair).
                    //
                    synchronizedResult.ClientData = new ClientData(
                        new AnyPair <ReturnCode, Result>(code, result));

                    //
                    // NOTE: If the original client data is valid and can be
                    //       cast to an event wait handle, signal it now.
                    //
                    if (clientData != null)
                    {
                        EventWaitHandle @event =
                            clientData.Data as EventWaitHandle;

                        if (@event != null)
                        {
                            /* IGNORED */
                            ThreadOps.SetEvent(@event);
                        }
                    }
                }
            }
        }