title: run asp.net function when The page is closing
body: <p>I have an asp.net page 
  when Loading this page it creates a Thread to do some thing
  My Question is :
  How to kill this thread when the user close the page ?
  I have tried with "onUnload" event
  but it just works with javascript function (as I know)
  and we can't use asp.net code in javascript function
  Do You have a way to help me ...
  thanks a lot</p>
  
  <p><strong>Edit:</strong>
  It 's difficult to explain what I am Trying to do.. The asp.net page must show a message to the user and this message must appear directly without refreshing so I was trying to use a thread which listen wait the message and then run an AJAX code to show the message ..</p>