Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Windows Service

Windows Service

Scheduled Pinned Locked Moved .NET (Core and Framework)
question
9 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    koleraba
    wrote on last edited by
    #1

    Hi I have to create a windows service. While browsing the internet I found a few articles which are taking about classes which should not be used in the windows service. So far I found the following. System.Timers.Timer System.Windows.Threading.DispatcherTimer System.ComponentModel.BackgroundWorker Is that correct? Are there any aditional classes which should not be used in a windows service? Thanks in advance. Uroš

    N C 2 Replies Last reply
    0
    • K koleraba

      Hi I have to create a windows service. While browsing the internet I found a few articles which are taking about classes which should not be used in the windows service. So far I found the following. System.Timers.Timer System.Windows.Threading.DispatcherTimer System.ComponentModel.BackgroundWorker Is that correct? Are there any aditional classes which should not be used in a windows service? Thanks in advance. Uroš

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      It depends more on what and how your service is going to be used.


      I know the language. I've read a book. - _Madmatt

      K 1 Reply Last reply
      0
      • K koleraba

        Hi I have to create a windows service. While browsing the internet I found a few articles which are taking about classes which should not be used in the windows service. So far I found the following. System.Timers.Timer System.Windows.Threading.DispatcherTimer System.ComponentModel.BackgroundWorker Is that correct? Are there any aditional classes which should not be used in a windows service? Thanks in advance. Uroš

        C Offline
        C Offline
        Covean
        wrote on last edited by
        #3

        In general you have to avoid everything that does something with the GUI. Services that try to open a window or something in that way will hang up (except services that can interact with the desktop, but don't use this anymore because it becomes obsolete). But you can use the class System.Timers.Timer in a service, you can't use the System.Windows.Forms.Timer!

        Greetings Covean

        K 1 Reply Last reply
        0
        • N Not Active

          It depends more on what and how your service is going to be used.


          I know the language. I've read a book. - _Madmatt

          K Offline
          K Offline
          koleraba
          wrote on last edited by
          #4

          What do you mean how? The service communicates with an .net application using WCF and than releys data to ethernet device using tcp sockets. Uroš

          N 1 Reply Last reply
          0
          • C Covean

            In general you have to avoid everything that does something with the GUI. Services that try to open a window or something in that way will hang up (except services that can interact with the desktop, but don't use this anymore because it becomes obsolete). But you can use the class System.Timers.Timer in a service, you can't use the System.Windows.Forms.Timer!

            Greetings Covean

            K Offline
            K Offline
            koleraba
            wrote on last edited by
            #5

            I know I should avoid anything that has to do with UI. But Background Worker does not exectly fit that criteria. Is the information regarding the Background worker event corrent?

            C 1 Reply Last reply
            0
            • K koleraba

              What do you mean how? The service communicates with an .net application using WCF and than releys data to ethernet device using tcp sockets. Uroš

              N Offline
              N Offline
              Not Active
              wrote on last edited by
              #6

              You seem to be missing the point. Perhaps more research on what a Windows service is, and isn't, will clarify it for you.


              I know the language. I've read a book. - _Madmatt

              1 Reply Last reply
              0
              • K koleraba

                I know I should avoid anything that has to do with UI. But Background Worker does not exectly fit that criteria. Is the information regarding the Background worker event corrent?

                C Offline
                C Offline
                Covean
                wrote on last edited by
                #7

                I can't see any reason why BackgroundWorker shouldn't work in a service. Its just using delegates and normal events. I also googled a little bit. It says it works on a service but this class is designed for UI purposes only so you shouldn't use it. Just use a normal Thread, this will work in any case.

                Greetings Covean

                K 1 Reply Last reply
                0
                • C Covean

                  I can't see any reason why BackgroundWorker shouldn't work in a service. Its just using delegates and normal events. I also googled a little bit. It says it works on a service but this class is designed for UI purposes only so you shouldn't use it. Just use a normal Thread, this will work in any case.

                  Greetings Covean

                  K Offline
                  K Offline
                  koleraba
                  wrote on last edited by
                  #8

                  I can't see it either. I just read it on: http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework/topic30104.aspx

                  C 1 Reply Last reply
                  0
                  • K koleraba

                    I can't see it either. I just read it on: http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework/topic30104.aspx

                    C Offline
                    C Offline
                    Covean
                    wrote on last edited by
                    #9

                    Did you read the last message on this board?

                    "It works fine in a console or service app with no forms. The delegates are run on thread pool threads instead of the UI thread. So there is nothing special going on, just delegates, BeginInvoke, and events. Try it yourself."

                    Greetings Covean

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups