示例#1
0
        /// <summary>
        /// Saves the byte array "datavalue" associated with a key "dataname" into the bucket "bucketname"
        /// </summary>
        public bool SaveByteArray(string bucketname, string dataname, byte[] datavalue, int maxretries)
        {
            // Save data
            bool result     = false;
            int  retrycount = maxretries;

            while (true)
            {
                // Try the insertion
                if (SaveByteArray(bucketname, dataname, datavalue))
                {
                    result = true;
                    break;
                }

                // Retry
                retrycount--;
                if (retrycount <= 0)
                {
                    break;
                }
                Thread.Sleep(Gadgets.ThreadRandomGenerator().Next(500, 2000));
            }

            // Return
            return(result);
        }
示例#2
0
        /// <summary>
        /// The method loads the byte array "datavalue" associated with a key "dataname" from the bucket "bucketname"
        /// </summary>
        public bool LoadByteArray(string bucketname, string dataname, out byte[] datavalue, int maxretries)
        {
            // Initialize results
            bool result = false;

            datavalue = null;

            // Load info
            int retrycount = maxretries;

            while (true)
            {
                // Try to load info
                if (LoadByteArray(bucketname, dataname, out datavalue))
                {
                    result = true;
                    break;
                }

                // Retry
                retrycount--;
                if (retrycount <= 0)
                {
                    break;
                }
                Thread.Sleep(Gadgets.ThreadRandomGenerator().Next(500, 2000));
            }

            // Return
            return(result);
        }
示例#3
0
        /// <summary>
        /// Insert a message in the queue and retry if an error is detected
        /// </summary>
        public bool EnqueueMessage(string msgbody, int maxretries)
        {
            // Insert domain info into queue
            bool result     = false;
            int  retrycount = maxretries;

            while (true)
            {
                // Try the insertion
                if (EnqueueMessage(msgbody))
                {
                    result = true;
                    break;
                }

                // Retry
                retrycount--;
                if (retrycount <= 0)
                {
                    break;
                }
                Thread.Sleep(Gadgets.ThreadRandomGenerator().Next(500, 2000));
            }

            // Return
            return(result);
        }