Thread is being abortted while deleting folders [closed]
I am usi开发者_StackOverflow社区ng web service method to run scripts it generated the some unwanted folders i want to delete folders after or before the script runs.
ProcessStatus newProcess =
new ProcessStatus(
String.Format(
"{0}, started:{1}",
projectName, DateTime.Now.ToString("HH:m:ss")
)
);
newProcess.buildData = new BuildHelper(deviceName, projectName, owner, deviceFolder, Constants.serverContentpath, Constants.buildInfoFilePath);
ProcessStatuses processStatus = new ProcessStatuses();
ArrayList allProcesses = processStatus.Get();
ArrayList.Synchronized(allProcesses).Add(newProcess);
ThreadPool.QueueUserWorkItem(
new WaitCallback(processStatus.startProcessing),
new object[] { newProcess, allProcesses }
);
//Thread th = new Thread(new ThreadStart(delegate {
// processStatus.startProcessing(new object[] { newProcess, allProcesses });
//}));
//th.Start();
processStatus = null;
newProcess = null;
_deviceBuildMonitor = null;
Let me first reframe your question as i understand.
Your webservice has created some temp files are you spawing off a thred to do some cleanup operations.
If your webservice is hosted on an IIS server then the problem could be that you IIS App pool is restarting on deletion(File Change Notification) of the directory. Try executing this code either in your app start event or before you try deleting the directory
var theRuntime = typeof(HttpRuntime).GetField("_theRuntime", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);
var fcmField = typeof(HttpRuntime).GetField("_fcm", BindingFlags.NonPublic | BindingFlags.Instance);
var fcm = fcmField.GetValue(theRuntime);
fcmField.FieldType.GetMethod("Stop", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(fcm, null);
精彩评论