CSDN博客

img optimizer

并非虚构...(一笑之)

发表于2002/3/27 17:57:00  429人阅读

并非虚构... (一笑之)

 

作者:Chris Sells

译者:荣耀

 

我的一个朋友在微软源码中意外发现了如下代码:

 

//Function:   RunCommandEx

//Synopsis:   runs the given command in the current session, more robust

//            than RunCommand

//Arguments:  none

//Returns:    S_OK if success

//History:    October 3, 2000 - created [name withheld to protect the guilty]

 

HRESULT RunCommandEx(LPCWSTR szCmdLine)

{

    DWORD dwTry = 0;

    HRESULT hResult = S_OK;

 

    //try run command 3 times at most

    while (dwTry<4)

    {

        hResult = RunCommand(szCmdLine);

        if (hResult!=E_FAIL)

        {

            //we succeeded

            break;

        }

        dwTry++;

     }

     if (dwTry==4)

     {

         ATLTRACE(L"COuld start the command even we tried 4 times/n");

         //译注:或许Chris的本意是

         //ATLTRACE(L"Couldn't start the command even we tried 4 times/n");

         ASSERT(FALSE);

     }

     return hResult;

}

 

这并非我所指的强健,但也不错...

0 0

相关博文

我的热门文章

img
取 消
img