Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9102379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:22:15+00:00 2026-06-17T01:22:15+00:00

I have created a WPF application.There are two threads running in my application: First

  • 0

I have created a WPF application.There are two threads running in my application:

  1. First thread listen asynchronously for TCP packets on PORT 40010 and push data to MSMQ
  2. Second thread pop data from MSMQ

When I close the application by clicking on window close button it shows no error.
But when I start the application again it throws the exception:

Unable to start Listrner : Only one usage of each socket address 
    (protocol/network address/port) is normally permitted

When I restart my PC it run first time successfully but on closing the application it does not work again

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T01:22:17+00:00Added an answer on June 17, 2026 at 1:22 am

    You shall not kill your threads.

    What you should do is to provide a nice way for them to finish. On close of your application you should set some variable:

    volatile bool shouldClose;
    

    and use that variable inside your threads say before poping next package and brake your infinite loop there.

    As for main application it should wait for your threads to finish.

    for volatile keyword see documentation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a wpf application ,there are two canvas i would like to
I have created a WPF application (named Ferhad.Wpf). Then I added two class libraries
I have created a wpf application into which I have added a user control
I have created some tests in my WPF application. Right now I am working
We have created a beautifully designed .NET WPF desktop application. We are installing the
We have created a WCF RESTful service for a WPF(UI) Application. The UI sends
I have created a desktop application in WPF that I wish to supply to
I have created two WindowSurface (WPF), and I want to navigate betwen them. I've
My WPF application is becoming a real pain. I have created a Window and
I have created an office add-in that holds an instance of a WPF Application.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.