title: System.Threading.ThreadAbortException: Thread was being aborted
body: <p>i am getting this error while executing the procedure. This problem occurs only at production not in the testing and developer systems. Also this problem does not occur all the time. When this error arises all users using this database through application are getting hanged that means all the users connections to the database are reset. It resumes and works fine after few seconds.</p>
  
  <p>The error message is</p>
  
  <pre><code>System.Threading.ThreadAbortException: Thread was being aborted.
     at SNIReadSync(SNI_Conn* , SNI_Packet** , Int32 )
     at SNINativeMethodWrapper.SNIReadSync(SafeHandle pConn, IntPtr&amp; packet, Int32 timeout)
     at System.Data.SqlClient.TdsParserStateObject.ReadSni(DbAsyncResult asyncResult, TdsParserStateObject stateObj)
     at System.Data.SqlClient.TdsParserStateObject.ReadNetworkPacket()
     at System.Data.SqlClient.TdsParser.ConsumePreLoginHandshake(Boolean encrypt, Boolean trustServerCert, Boolean&amp; marsCapable)
     at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity)
     at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject)
     at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout)
     at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
     at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
     at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
     at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
     at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
     at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
     at System.Data.SqlClient.SqlConnection.Open()
     at Project1.Library.dbconn.OpenConn()
     at Project1.Library.clsUserMenuDAL.SubChildMenu(clsUserMenuBAL obj)
  </code></pre>
  
  <p>The stored procedure that i am using is given below,</p>
  
  <pre><code>Alter PROCEDURE [dbo].[proc_LoadMainMenu]  
   @User_Gid [int] = 0,  
   @profile_gid [int] = 0,  
   @soft_gid [int] = 0  
  
  WITH EXECUTE AS CALLER  
  AS  
  BEGIN  
   -- SET NOCOUNT ON added to prevent extra result sets from  
   -- interfering with SELECT statements.  
   SET NOCOUNT ON;  
      -- Insert statements for procedure here  
      declare @lsquery varchar(max)  
   set @lsquery=' select menu_gid,menu_desc,menu_link,menu_reportorder from qad_adm_tmenu a '  
   set @lsquery =@lsquery+' inner join qad_adm_tprofilerights b on b.profilerights_menugid=a.menu_gid'  
   set @lsquery =@lsquery+' inner join qad_map_tuserprofile c on c.userprofile_profilerightsgid=b.profilerights_gid'  
   set @lsquery =@lsquery+' where c.Userprofile_usergid ='+ convert(varchar(20),@User_Gid) + 'and c.userprofile_profilegid = ' + convert(varchar(20),@profile_gid) + ''  
   set @lsquery =@lsquery+' and a.menu_softgid= '+ convert(varchar(20),@soft_gid) +' and a.menu_ordernumber =2'  
   set @lsquery =@lsquery+' and c.Userprofile_isremoved = ''N'' and userprofile_profilerightsaccess=''Y''  
   order by menu_reportorder '  
  
   exec(@lsquery)  
  
  END  
  </code></pre>
  
  <p>Thanks In Advance...</p>