Bogus local variable never used message

The following code incorrectly shows threadRegistryWatch and Time Delay as local variables that are never used.


0)
          {
            Thread.Sleep(TimeDelay); // Give all the changes time to come through
            HandleRegistryChange();
            Interlocked.Decrement(ref m_nOutstandingRegistryChanges);
          }
          // Store activity information in registry for the foreground dialog to retrieve
          GetCurrentActivity();
        }
      }
      catch (Exception x)
      {
        try
        {
          // Service has crashed
          RegistryKey regKeyActivity = Registry.LocalMachine.CreateSubKey(Global.RegistryKeyActivity);
          if (regKeyActivity!=null)
          {
            // Write the status to the registry for display on the console
            regKeyActivity.SetValue(Global.RegistryValueActivity, "0,0,0,0 Service: " + x.Message.Replace("\r", string.Empty).Replace("\n", string.Empty) + "\r\n");
            regKeyActivity.Close();
          }
        }
        catch // ignore errors in here
        {
        }
      }
    }]]>

2 comments
Comment actions Permalink

Could you, please, post this as a bug into our tracker?

--
Andrey Simanovsky
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"



"Sam Mackrill" <no_mail@jetbrains.com> wrote in message
news:18250676.1089991182713.JavaMail.itn@is.intellij.net...

The following code incorrectly shows threadRegistryWatch and Time Delay as

local variables that are never used.
>
>
>

     {
>       try
>       {
>         // Load the configuration information
>         m_configInfo = new ConfigInfo();
>         m_configInfo.LoadInformationFromRegistry(true);
>         EventLogUtil.UseClickstreamEventLog =
m_configInfo.UseClickstreamEventLog;
>         EventLogUtil.ReportAnInformationEvent("Service started");
>         m_configInfo.StartThreads(ActivityInfoList);
>         // Start the thread which monitors the registry key for changes
>         Thread *threadRegistryWatch* = new Thread(new
ThreadStart(RegistryWatch));
>         threadRegistryWatch.Start();
>         while (true)
>         {
>           TimeSpan *TimeDelay* = new TimeSpan(0, 0, 2);
>           Thread.Sleep(TimeDelay);
>           // Has there a registry change? (this doesn't need to be
interlocked)
>           if (m_nOutstandingRegistryChanges>0)
>           {
>             Thread.Sleep(TimeDelay); // Give all the changes time to come
through
>             HandleRegistryChange();
>             Interlocked.Decrement(ref m_nOutstandingRegistryChanges);
>           }
>           // Store activity information in registry for the foreground
dialog to retrieve
>           GetCurrentActivity();
>         }
>       }
>       catch (Exception x)
>       {
>         try
>         {
>           // Service has crashed
>           RegistryKey regKeyActivity =
Registry.LocalMachine.CreateSubKey(Global.RegistryKeyActivity);
>           if (regKeyActivity!=null)
>           {
>             // Write the status to the registry for display on the console
>             regKeyActivity.SetValue(Global.RegistryValueActivity, "0,0,0,0
Service: " + x.Message.Replace("\r", string.Empty).Replace("\n",
string.Empty) + "\r\n");
>             regKeyActivity.Close();
>           }
>         }
>         catch // ignore errors in here
>         {
>         }
>       }
>     }]]>



0

Please sign in to leave a comment.