我正在使用线程来检查服务器上的现有数据,这个线程使用了50个CPU [英] I am using thread to check a existing of data on sever this thread utilized 50 of CPU
本文介绍了我正在使用线程来检查服务器上的现有数据,这个线程使用了50个CPU的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Dim check As Thread
Private Sub RunThread()
Dim newThread1 As New ThreadStart(AddressOf Checkdata)
check = New Thread(newThread1)
check.Start()
End Sub
Private Sub Checkdata()
Dim dt As Date
Dim dset As DataSet
Dim prr() As Object
dt = Date.Now.AddMinutes(5)
For i As Integer = 0 To 5
If Date.Now > dt Then
dt = Date.Now.AddMinutes(1)
prr = {objBranch.BranchKey}
Try
Dim objUIDataGetBranch As BranchSelectionFetch.UIDataWCFClient
objUIDataGetBranch = New BranchSelectionFetch.UIDataWCFClient("IndependentFetchDataEndPtHttp")
byteBranchSelectionData = objUIDataGetBranch.WCFAuxValuesByte(CRisMACEntity.ApplicationDown, prr)
objUIDataGetBranch.Close()
prr = Nothing
DecompressData(byteBranchSelectionData)
dset = ds
Catch ex As Exception
End Try
If dset IsNot Nothing Then
If dset.Tables(0).Rows.Count > 0 Then
Application.ExitThread()
Application.Exit()
Application.DoEvents()
check.Abort()
End If
End If
End If
i = 0
Next
End Sub
这里是Code如何减少cpu利用率任何一个帮助
谢谢
Here is Code how Can i reduce cpu utilization Any One Help
Thanks
推荐答案
在Next
语句之前放置一个Thread.Sleep(15000)。
这将迫使线程进入休眠状态15秒,释放CPU以执行其他操作。
嗯...Application.ExitThread()
,Application.Exit()
和Application.DoEvents()
电话?你不需要任何一个。摆脱它们。
Put a Thread.Sleep(15000) just before yourNext
statement.
This will force the thread to go to sleep for 15 seconds freeing up the CPU to do other things.
Ummm...What's with theApplication.ExitThread()
,Application.Exit()
andApplication.DoEvents()
calls? You don't need any of them. Get rid of them.
这篇关于我正在使用线程来检查服务器上的现有数据,这个线程使用了50个CPU的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文