none
System.Threading.Timer.Change raising Exception from HRESULT: 0x8007001F RRS feed

  • Question

  • Hello we have a class library that is developed in C# that is registered for COM Interop to use in our legacy MFC application. Internal to the class library we up a System.Threading.Timer as follows. 
    this._tokenExpireTimer = new Timer(new TimerCallback(this._tokenExpireTimer_Callback));
    this._tokenExpireTimer.Change(-1, -1);


    After some other initialization stuff we call the function below.

     
    private void SetupTokenTimerExpire(long tokenExpire)
     {
          long num;
          long num2 = (tokenExpire / 0x3e8L) - 0x493e0L;
          long num3 = (long)((tokenExpire / 0x3e8L) * 0.6);
          if (num2 > num3)
          {
            num = num2;
          }
          else
          {
            num = num3;
          }
          try
          {
            this._tokenExpireTimer.Change(num, -1L);
          }
          catch (Exception ex)
          {
            Debug.WriteLine(ex.Message);
            Debug.WriteLine(ex.StackTrace.ToString());
            Debug.WriteLine(ex.InnerException.ToString());
          }
    }
    


    The num parameter passed into the _tokenExpireTimer.Change function is usually 144,000. Whenever we call the "Change" function the following exception is raised.

    A first chance exception of type 'System.ApplicationException' occurred in mscorlib.dll
    A device attached to the system is not functioning. (Exception from HRESULT: 0x8007001F)
       at System.Threading.TimerBase.ChangeTimerNative(UInt32 dueTime, UInt32 period)
       at System.Threading.TimerBase.ChangeTimer(UInt32 dueTime, UInt32 period)
       at System.Threading.Timer.Change(Int64 dueTime, Int64 period)
       at VSystem.VSystemWrapper.SetupTokenTimerExpire(Int64 tokenExpire) in d:\Projects\Templates\VSystem\VSystem\Class1.cs:line 339

    I can create new MFC application and and import the control and everything works like a champ. When it is called from our legacy application it always raises and exception in the same spot. Our legacy app was originally developed in VS 6.0 and has been upgraded over time so I am not sure if that has anything to do with it. I am just not sure where to go now. Looking forward to your responses.
    Thursday, April 22, 2010 8:06 PM

Answers

  • Hi gmc3,

    According to your description, I trid to write down some simple codes to reproduce the problem. However, I failed. Could you please show me more details or just a pieces of code sample to help me reproduce what you are facing now.

    And since I can not reproduce it, I try to google the HRESULT Number, it seems to be something wrong with your hardware, however, I'm not sure about this issue. When you google "A device attached to the system is not functioning.", you will find a lot links, like:

    Good luck and have a nice day!


    Hope this helpful to you! If you have any further quetions, please feel free to let me know.
    Please mark the right answer at right time.
    Bset Regards,
    Tracy
    • Marked as answer by eryang Wednesday, April 28, 2010 9:16 AM
    Tuesday, April 27, 2010 10:00 AM

All replies

  • Hi gmc3,

    According to your description, I trid to write down some simple codes to reproduce the problem. However, I failed. Could you please show me more details or just a pieces of code sample to help me reproduce what you are facing now.

    And since I can not reproduce it, I try to google the HRESULT Number, it seems to be something wrong with your hardware, however, I'm not sure about this issue. When you google "A device attached to the system is not functioning.", you will find a lot links, like:

    Good luck and have a nice day!


    Hope this helpful to you! If you have any further quetions, please feel free to let me know.
    Please mark the right answer at right time.
    Bset Regards,
    Tracy
    • Marked as answer by eryang Wednesday, April 28, 2010 9:16 AM
    Tuesday, April 27, 2010 10:00 AM
  • Hi gmc3,

    It seems you got the right answer, so I marked it.

    If you have any further questions, please feel free to unmark it and we will discuss this issue again.

    Have a nice day!


    Sincerely,
    Eric
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact msdnmg@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Wednesday, April 28, 2010 9:17 AM