Esempio n. 1
0
        /// <summary>
        /// Puts a message onto a queue.
        /// </summary>
        /// <param name="QueueName">Queue name.</param>
        /// <param name="Message">Message</param>
        public Task PutAsync(string QueueName, string Message)
        {
            PutTask Item = new PutTask(this, QueueName, Message);

            MqTasks.ExecuteTask(Item);
            return(Item.Completed);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets one message from a queue.
        /// </summary>
        /// <param name="QueueName">Name of queue.</param>
        /// <param name="TimeoutMilliseconds">Timeout, in milliseconds.</param>
        /// <returns>Message read, if received within the given time, null otherwise.</returns>
        public Task <string> GetOneAsync(string QueueName, int TimeoutMilliseconds)
        {
            GetTask Item = new GetTask(this, QueueName, TimeoutMilliseconds);

            MqTasks.ExecuteTask(Item);
            return(Item.Completed);
        }
Esempio n. 3
0
        /// <summary>
        /// Connects to the Queue Manager asynchronously.
        /// </summary>
        /// <param name="UserName">User name</param>
        /// <param name="Password">Password</param>
        public Task ConnectAsync(string UserName, string Password)
        {
            ConnectionTask Item = new ConnectionTask(this, UserName, Password);

            MqTasks.ExecuteTask(Item);
            return(Item.Completed);
        }
Esempio n. 4
0
        /// <summary>
        /// Subscribes to incoming messages.
        /// </summary>
        /// <param name="QueueName">Queue name.</param>
        /// <param name="Cancel">Cancel event. Set this event object, to cancel subscription.</param>
        /// <param name="Stopped">Optional Event that will be set when the subscription has ended.</param>
        /// <param name="Callback">Method to call when new message has been read.</param>
        /// <param name="State">State object to pass on to callback method.</param>
        public void SubscribeIncoming(string QueueName, ManualResetEvent Cancel, TaskCompletionSource <bool> Stopped,
                                      MqMessageEventHandler Callback, object State)
        {
            this.Information("Subscribing to messages from " + QueueName);
            SubscriptionTask Item = new SubscriptionTask(this, QueueName, Cancel, Stopped, Callback, State);

            MqTasks.ExecuteTask(Item);
        }