Hello
I have written the following in console application.
My problem is I want the application running in the back.
and it should check every thirty minutes and update thedatabase
the problem is that the threading does not work
and to make the application run every thirty minutes am i suppose to create a windows service.
Please let me know
Thanks - Sub Main()
-
Dim Th As New Thread(AddressOf CheckTimeDifference)
-
-
Th.Start()
-
-
-
End Sub
-
Private Sub CheckTimeDifference()
-
-
Try
-
-
MyCon = New SqlConnection("server=ccccccc;uid=;pwd=;database=ee")
-
MyCon.Open()
-
-
chkTime = Now
-
StrSql1 = "Select REGISTRATIONNO,MAX(GPS_DATETIME) FROM GPSDATA_HISTORY group by REGISTRATIONNO"
-
MyCmd = New SqlCommand(StrSql1, MyCon)
-
-
Da = New SqlDataAdapter(StrSql1, MyCon)
-
Ds = New DataSet()
-
Da.Fill(Ds, "ChkTable")
-
-
RowCount = (Ds.Tables("ChkTable").Rows.Count)
-
For I = 0 To RowCount - 1
-
-
RegNo = (Ds.Tables("chktable").Rows(I)(0))
-
dataTime = (Ds.Tables("chktable").Rows(I)(1))
-
-
TimeDiff = DateDiff(DateInterval.Minute, dataTime, chkTime)
-
If TimeDiff > 30 Then
-
StrSql1 = "Update gpsdata set speed=0 ,ignition=0 where registrationno='"
-
StrSql2 = RegNo & "'"
-
StrSql = StrSql1 + StrSql2
-
MyCmd1 = New SqlCommand(StrSql, MyCon)
-
MyCmd1.ExecuteNonQuery()
-
Console.WriteLine("Speed details, Ignition Details has been changed in GPS DATA")
-
StrSql3 = "Update gpsdata_history set speed=0 ,ignition=0 where registrationno='"
-
StrSql4 = RegNo & "' and gps_datetime='" & dataTime & "'"
-
StrSql5 = StrSql3 + StrSql4
-
MyCmd2 = New SqlCommand(StrSql5, MyCon)
-
MyCmd2.ExecuteNonQuery()
-
Console.WriteLine("Speed details, IgnitionDetails has been changed in GPSDATAHISTORY")
-
End If
-
-
Next
-
-
Catch e As Exception
-
-
Console.WriteLine(e.ToString)
-
Thread.Sleep(60000)
-
-
End Try
-
-
End Sub
-
End Module
3 1850
Hello
I have written the following in console application.
My problem is I want the application running in the back.
and it should check every thirty minutes and update thedatabase
the problem is that the threading does not work
and to make the application run every thirty minutes am i suppose to create a windows service.
Please let me know
Thanks - Sub Main()
-
Dim Th As New Thread(AddressOf CheckTimeDifference)
-
-
Th.Start()
-
-
-
End Sub
-
Private Sub CheckTimeDifference()
-
-
Try
-
-
MyCon = New SqlConnection("server=ccccccc;uid=;pwd=;database=ee")
-
MyCon.Open()
-
-
chkTime = Now
-
StrSql1 = "Select REGISTRATIONNO,MAX(GPS_DATETIME) FROM GPSDATA_HISTORY group by REGISTRATIONNO"
-
MyCmd = New SqlCommand(StrSql1, MyCon)
-
-
Da = New SqlDataAdapter(StrSql1, MyCon)
-
Ds = New DataSet()
-
Da.Fill(Ds, "ChkTable")
-
-
RowCount = (Ds.Tables("ChkTable").Rows.Count)
-
For I = 0 To RowCount - 1
-
-
RegNo = (Ds.Tables("chktable").Rows(I)(0))
-
dataTime = (Ds.Tables("chktable").Rows(I)(1))
-
-
TimeDiff = DateDiff(DateInterval.Minute, dataTime, chkTime)
-
If TimeDiff > 30 Then
-
StrSql1 = "Update gpsdata set speed=0 ,ignition=0 where registrationno='"
-
StrSql2 = RegNo & "'"
-
StrSql = StrSql1 + StrSql2
-
MyCmd1 = New SqlCommand(StrSql, MyCon)
-
MyCmd1.ExecuteNonQuery()
-
Console.WriteLine("Speed details, Ignition Details has been changed in GPS DATA")
-
StrSql3 = "Update gpsdata_history set speed=0 ,ignition=0 where registrationno='"
-
StrSql4 = RegNo & "' and gps_datetime='" & dataTime & "'"
-
StrSql5 = StrSql3 + StrSql4
-
MyCmd2 = New SqlCommand(StrSql5, MyCon)
-
MyCmd2.ExecuteNonQuery()
-
Console.WriteLine("Speed details, IgnitionDetails has been changed in GPSDATAHISTORY")
-
End If
-
-
Next
-
-
Catch e As Exception
-
-
Console.WriteLine(e.ToString)
-
Thread.Sleep(60000)
-
-
End Try
-
-
End Sub
-
End Module
Problem Resolved
Put a dowhile loop
and put the thread sleep after end try
Problem Resolved
Put a dowhile loop
and put the thread sleep after end try
I have created a windows installer using VB.net 2005
(as per msdn link given below)
http://msdn2.microsoft .com/en-us/library/zt39148a(VS.80) .aspx
Now I need to include the above said application inside the windows service.
How to do?
I have created a windows installer using VB.net 2005
(as per msdn link given below)
http://msdn2.microsoft .com/en-us/library/zt39148a(VS.80) .aspx
Now I need to include the above said application inside the windows service.
How to do?
Problem Solved
Installed it in windows service
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Keyee Hsu |
last post by:
Hi, I have a C# app that creates an AppDomain, enters it, and spawns an
asyn thread to do some work and then block itself. Upon the completion
of the work, the async thread supposedly terminates, then the original
thread unblocks, unloads the AppDomain, and starts the whole process all
over again. I get the System.AppDomainUnloadedException saying that the
AppDomain from which the async thread resides has been unloaded. Now,
if I were...
|
by: Leonardo Hyppolito |
last post by:
Hello,
I am trying to write a multithread program that simulates producers and
consumers. My program can have many producers and many consumers (each in a
separate thread). It has a storage place (buffer) with "n" capacity. The
user provides these parameters on startup. The buffer works with a circular
queue.
It's a console application. My implementation is working with Semaphores
to synchornize everything. I think it's synchornized...
|
by: Daniel |
last post by:
i have an array that i want all threads to be able to READ from
concurrently, however, at times i want to UPDATE the array. at which point i
want all threads that use it to block when they try to read from the array.
currently i do this by wrapping ALL READ AND WRITE access to the array in a
lock("foobar"){} this prevernts threads from reading from the array while it
is being written to however it ALSO keeps more then one thread from...
|
by: lukasz |
last post by:
Hi, could somebody analyze a class and suggest what to do to avoid
hanging the class (thread) when the application calling it exits? (Other
than using background threads). This class is something similar to a
splash screen. Thanks
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Threading;
|
by: Raj Wall |
last post by:
Hi,
I have an application that uses a number of sub-threads.
What is the best way to do some processing in each thread when the main
application is shut down?
Is the ThreadAbortException thrown automatically for each thread? Or is
there some other event or exception automatically thrown that the thread can
"grab" as it is shut down?
| |
by: Carl Heller |
last post by:
If I'm creating a class to do some work that I want threaded out, where's
the best location to call ThreadStart? Or does it depend on the nature of
the work?
a. Call it outside the class, giving it the starting method of the class?
b. Have the class create the thread itself?
ie:
x = new WorkerClass();
ioThread = new Thread(new ThreadStart(x.StartWork));
|
by: =?Utf-8?B?anAybXNmdA==?= |
last post by:
I have a windows application that does not stop running whenever the
application exits.
Could someone fill me in on what I am doing wrong?
Here is the relevant code:
=================================
Private m_thTCP As Thread
Private m_listener As TcpListener
|
by: =?Utf-8?B?anAybXNmdA==?= |
last post by:
I've got a routine that builds a table using different queries, different SQL
Tables, and adding custom fields.
It takes a while to run (20 - 45 seconds) so I wrote a thread to handle the
table population.
Whenever I call the thread, I pass it a structure containing the table and a
few other parameters. The table goes in as a reference, but the other items
are passed normally.
|
by: yeye.yang |
last post by:
hey everybody
Does everybody can help me or give me some advise for the cross thread
exception catch
Here is what I want to do:
I have 2 classes "Scenario" and "Step", which have a
System.Thread.Timer for each to control their timeout gestion, in my
"main program", I start the "Scenario" and "Step", and I do something
between "StepStart" and "StepStop", when "Scenario" or "Step" timeout
expired, they raise an "exception", then my "main...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |