Rick

Rick

  • NA
  • 3
  • 0

Threading not working within Sharepoint Portal...

Aug 4 2006 7:26 PM
I am currently working on a large scale web-portal utilizing sharepoint written in ASP.net.  I need to be able to start a new thread from one of my web-parts.  That performs a lengthy process in which I pull records into a dataset and then create an Access DB that I insert the rows into.  This process could take 2 - 15 minutes.  My thread works fine within my development environment, however... when I  post the code to my Sharepoint server as soon as the thread is executed it dies... 

Is it possible to spawn a thread within a Sharepoint portal? 

If so how?

Currently my code looks like this...  Pretty basic...  I've even tried passing credentials to the method that the thread.  If anyone out there has done this I would greatly appreciate your insight.  Thanks in advance...

private void CallingMethod()
{
   ThreadStart tStart = new ThreadStart(ThreadExportData);
   Thread thread = new Thread(tStart);
   thread.Priority = ThreadPriority.BelowNormal;
   thread.CurrentCulture = Thread.CurrentThread.CurrentCulture;
   thread.Start();
}

private void ThreadExportData()
{

WindowsIdentity id = WindowsIdentity.GetCurrent();

 id.Impersonate();

//Do work here..

id.Impersonate.Undo();
}

Answers (1)