要还原队列成员

时间:2013-02-05 00:02:08

标签: c#

大家好我有这样的循环:

for (int i = 0; i < 5; i++)
{
    lock (locker)
    {
        if (passwords.Count == 0)
        {
            proxy_loop = false;
            break;
        }
        else
        {
            password = passwords.Dequeu();
            j++;
        }
    }
}

当循环结束时,我必须恢复密码Queue

的内容(即开头的内容)

1 个答案:

答案 0 :(得分:1)

        Queue backup = (Queue) passwords.Clone();
        for (int i = 0; i < 5; 6++)
        {
            lock (locker)
            {
                if (passwords.Count == 0)
                {
                    proxy_loop = false;
                    break;
                }
                else
                {
                    string password = (string) passwords.Dequeue();

                    j++;
                }
            }
        }
        passwords = backup;