davers's Profile User Rating: -----

Reputation: 1 Apprentice
Group:
Active Members
Active Posts:
59 (0.05 per day)
Joined:
07-April 11
Profile Views:
1,037
Last Active:
User is offline Apr 01 2013 07:26 AM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   davers has not set their status

Posts I've Made

  1. In Topic: Windows service and LDAP change notifications

    Posted 22 Mar 2013

    Hmm...Ok, I guess I'm confused again. So I need to put a stop in there even though the connection needs to remain open to receive AD LDS change notifications? :helpsmilie:

    Dave
  2. In Topic: Windows service and LDAP change notifications

    Posted 22 Mar 2013

    Wow! I can't believe this took so long to click in my head. So, I'm pretty sure this is what you were talking about:

            protected override void onstart(string[] args)
            {
                thread = new Thread(this.WorkerThread);
                thread.Start();
    
                myDte1 = DateTime.Now.ToString(GlobalVariables.logFileFormat);
                myDte2 = DateTime.Now.ToString(GlobalVariables.logFormat);
                myDte3 = DateTime.Now.ToString("G");
    
                string myString1 = String.Format("[" + myDte2 + "] SERVICE : Service started...");
    
                using (StreamWriter w = File.AppendText(GlobalVariables.myLogFldr + "SPSChange.log." + myDte1 + ".txt"))
                {
                    Log(myString1, w);
                }  
            }
    
            public void WorkerThread()
            {
                try
                {
                    ChangeNotifier notifier = new ChangeNotifier(connect);
    
                    notifier.Register("OU=ACDAgents,OU=CM,OU=DEFINITY Servers,OU=dem,DC=starfish", SearchScope.Subtree);
                    notifier.ObjectChanged += new EventHandler<ObjectChangedEventArgs>(notifier_ObjectChanged);
    
                    string myString2 = String.Format("[" + myDte2 + "] DEBUG : Connected to DEM!");
    
                    using (StreamWriter w = File.AppendText(GlobalVariables.myLogFldr + "SPSChange.log." + myDte1 + ".txt"))
                    {
                        Log(myString2, w);
                    }
                }
                catch (Exception ex)
                {
                    string myString3 = String.Format("[" + myDte2 + "] ERROR : Can not connect to DEM! - " + ex.Message);
    
                    using (StreamWriter w = File.AppendText(GlobalVariables.myLogFldr + "SPSChange.log." + myDte1 + ".txt"))
                    {
                        Log(myString3, w);
                    }
                }
    
                while (true)
                {
                    myDte1 = DateTime.Now.ToString(GlobalVariables.logFileFormat);
                    myDte2 = DateTime.Now.ToString(GlobalVariables.logFormat);
                    myDte3 = DateTime.Now.ToString("G");
    
                    string myString1 = String.Format("[" + myDte2 + "] HEARTBEAT : I'm running already!!");
    
                    using (StreamWriter w = File.AppendText(GlobalVariables.myLogFldr + "SPSChange.log." + myDte1 + ".txt"))
                    {
                        Log(myString1, w);
                    }
    
                    Thread.Sleep(300000);
                }
            }
    


    there's a lot of logging stuff that's in there...but I think you'll see the threading I'm using. I have it write to my log every 5 minutes just so I know it's still there. Is that what you had in mind Skydiver?

    Thanks again for all your help!!!

    Dave
  3. In Topic: Windows service and LDAP change notifications

    Posted 20 Mar 2013

    Hey Gang! I've tried implementing what Skydiver has suggested above, and my service works in "debug" mode, but I can't get it to install. I get error 1053: "The service did not respond to the start or control request in a timely fashion". I've read that that can be to the service getting stuck in an eternal loop...etc. I'm wondering if perhaps the:

                        while (_keepGoing)
                            ;
    


    could be the cause? Does anyone have any ideas?

    Thanks!

    Dave
  4. In Topic: Windows service and LDAP change notifications

    Posted 23 Feb 2013

    Hey again! I've been googling all day and wracking my brain, and I can't seem to figure this out. I think you are right Skydiver, but I can't seem to find an example of the EventWaitHandle that corresponds to what I am trying to do. Any push in the right direction would be greatly appreciated!

    Thanks,

    Dave
  5. In Topic: Windows service and LDAP change notifications

    Posted 23 Feb 2013

    Hey Skydiver! Thanks for the reply! I'm glad you had a BINGO moment, :bigsmile: but do you have any idea how to keep that thread alive?

    Thanks again!!!

    Dave

My Information

Member Title:
D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Click here to e-mail me

Friends

davers hasn't added any friends yet.

Comments

davers has no profile comments yet. Why not say hello?