I created a windows application service that runs every 20 seconds to collect data from avaya cms and then dump it into a database. I did this using a timer. Since I had to have access to the clipboard to get the data and parse it, I had to be in STA. Unfortunately, just putting the STA before the Main() (or any other sub) did not keep the service in single thread mode. So I had to create a new thread and join it like so:
At this point my program can access the clipboard and the script works fine for a while. Unfortunately, after a few hours (ranges from 1.5 to 17 hours) cpu utilization on the service hits 100% and the server must be rebooted. I'm not sure what is causing this but I wondered if perhaps the threads I'm creating are somehow building up and taking over the cpu? No error shows up in the event viewer (also, I've not managed to get try/catch to work in my windows service, but it usually writes to the event viewer on errors anyway.)
I can post the entire script if necessary. Would appreciate any help!
VB.NET:
Dim cbThread As New Thread(New ThreadStart(AddressOf CopyToClipboard)) cbThread.SetApartmentState(System.Threading.ApartmentState.STA)
cbThread.Start()
If Not cbThread Is Nothing Then
If Not cbThread.Join(100) Then
cbThread.Abort()
End If
End If
At this point my program can access the clipboard and the script works fine for a while. Unfortunately, after a few hours (ranges from 1.5 to 17 hours) cpu utilization on the service hits 100% and the server must be rebooted. I'm not sure what is causing this but I wondered if perhaps the threads I'm creating are somehow building up and taking over the cpu? No error shows up in the event viewer (also, I've not managed to get try/catch to work in my windows service, but it usually writes to the event viewer on errors anyway.)
I can post the entire script if necessary. Would appreciate any help!
Last edited: