WCF:: ServiceHost: Oddity…Still alive even if thread is dead?

前端 未结 1 1645
名媛妹妹
名媛妹妹 2021-01-20 12:04

a new member here. Nice to see such a neat community.

After a bit of research, I decided to use WCF in my application to do inter process communication, so I am usin

相关标签:
1条回答
  • 2021-01-20 12:08

    When you call Open on the ServiceHost, an additional thread will be created to listen for incoming service requests. In this way, your thread may have finished running, but another thread has been created, and will continue to run until you call "Close" on the ServiceHost.

    It may not be necessary in your case to spawn off a thread yourself. Just Open your ServiceHost in the application's main thread. You can then do other things in your main thread, and when you're ready to kill the host, just call serviceHost.Close().

    Here's a pretty good description I found:

    http://www.code-magazine.com/article.aspx?quickid=0701041&page=1

    0 讨论(0)
提交回复
热议问题