HELP ASAP....Windows Service Errors....passing information from .cs file to another .cs file

Sorry to be such a novice about this but..... I have a windows service. It contains two separate files. Both have the same namespace name.

I need to pass "bDisplay" into the other file. I am getting several errors and not sure why or how to solve them does anyone have any help?

How do I access the other file?

ServerSocket.cs *This is where the main server start is so the" private bool m_bIsDisplayed = false;" had to go here so it didn't reset every time.

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
using System.Runtime.InteropServices;
using System.Net.Sockets;
using System.IO;
using System.Net;      
using Listener;
using System.Threading;

namespace Listener
{
 private bool m_bIsDisplayed = false;

      public bool GetIsDisplayed()
      {
         return m_bIsDisplayed();
      }

      public void SetIsDisplayed(bool bDisplay)
      {
         m_bIsDisplayed = bDisplay;
      }

}

SocketListner.cs

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Runtime.InteropServices;
using System.Net.Sockets;
using System.Threading;
using System.Text;
using System.IO;
using System.Xml;
using System.Xml.XPath;
using System.Web;
using System.Windows.Forms;

using Listener;

namespace Listener
{

 private void MsgBxDisplayed(Byte [] byteBuffer, int size)
      {
         string sData = Encoding.ASCII.GetString(byteBuffer,0, size);  

         try
         {
            if (m_bIsDisplayed == true)
                 ///Need pass variable here of TRUE or FALSE so it doesn't continue with the default everytime.
            {
             
              System.Diagnostics.EventLog.WriteEntry(this.ToString(),sData);

            }
            else if (m_bIsDisplayed == false)
            {
               
               m_bIsDisplayed = true;
               System.Diagnostics.EventLog.WriteEntry(this.ToString(),sData);

               
           
               DialogResult result = MessageBox.Show("Failure", "WARNING!!", MessageBoxButtons.OK,
                               MessageBoxIcon.Error, MessageBoxDefaultButton.Button1,
                               MessageBoxOptions.ServiceNotification);

               if(result == DialogResult.OK)
               {
                  // Closes the parent form.
                  //this.Close();
                  m_bIsDisplayed = false;
               }

            }

         }
         catch (Exception e)
         {
            System.Diagnostics.EventLog.WriteEntry(this.ToString(),
            "invalid IsDisplayed" + e.Message);
         }
         }

errors:

error CS0118: 'Listener.ServerSocket.m_bIsDisplayed' denotes a 'field' where a 'method' was expected
error CS0103: The name 'm_bIsDisplayed' does not exist in the class or namespace 'Listener.SocketListener'
error CS0103: The name 'm_bIsDisplayed' does not exist in the class or namespace 'Listener.SocketListener'
error CS0103: The name 'm_bIsDisplayed' does not exist in the class or namespace 'Listener.SocketListener'
error CS0103: The name 'm_bIsDisplayed' does not exist in the class or namespace 'Listener.SocketListener'
error CS0103: The name 'm_bIsDisplayed' does not exist in the class or namespace 'Listener.SocketListener'

LVL 2
NewMom2BrandonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PaulCaswellCommented:
In your GetIsDisplayed method, try changing:

        return m_bIsDisplayed();

to

        return m_bIsDisplayed;

Paul
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NewMom2BrandonAuthor Commented:
Thank you that takes care of one of my errors.
0
PaulCaswellCommented:
P.S.

Generally, if you have a 'Set' method and a 'Get' method for a property, you use it. I.E. In MsgBxDisplayed, you should not use m_bIsDisplayed, you should use Get/SetIsDisplayed(...).

Paul
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

NewMom2BrandonAuthor Commented:
I tried to run it in my MsgBxDisplayed but the problem is that this is a modal messagebox and if the user does not click the box closed it continually resets to false as if it where getting the request for the first time everytime...
So I have to place it into the first .cs file where the server is started (socketing)...so the IsDisplayed doesn't get reset to the default everytime.

So I need to pass it from one file (where the heart of the program is so to speaK) to the other.

0
PaulCaswellCommented:
>>Thank you that takes care of one of my errors.
Looking at it again, I'd guess that if you read and execute my P.S. that may remove your other errors too.

Paul
0
NewMom2BrandonAuthor Commented:
I tried it and it did get rid of the errors but does not give me the correct value.
0
PaulCaswellCommented:
Hmmm... I'd guess this is C# or something like it? I'm not familliar with the innards of C#. Perhaps you should get this question moved to the specific language topic rather than the general 'Programming' topic. Post a request with the mods and they'll move it.

Good luck. Remember me when the points are going down!! ;)

Paul
0
PaulCaswellCommented:
This is just a guess but it might be something about:

 private bool m_bIsDisplayed = false;

causing the flag to always be set to false on every invocation of the Get/Set methods. Is there a specific place where initialisors are place in this language? Is it C#?

Paul
0
NewMom2BrandonAuthor Commented:
I kept getting it to automatically default to false when it was in the file where the MsgBxDisplayed function is at. So I moved it into the main part which is a different file. I think this will make the application able to not reset automatically everytime the message comes in to me.

That is my thoery so I was putting it into the other file...to test my theory and I have to get the one file to be able to access it from the other file.

Oh boy I hope that makes sense
0
PaulCaswellCommented:
Makes sense!!! Good thinking!!! I am a 'C' and 'C++'(slightly) programmer. Correct me if I'm wrong but this int 'C++' is it?? So, sadly, I cant advise you on the initialisation/creator/destructor mechanisms here.

Paul
0
NewMom2BrandonAuthor Commented:
Nope it is C#

I will remember you for points though!!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.