Home Page
Articoli
Tips & Tricks
News
Forum
Archivio Forum
Blogs
Sondaggi
Rss
Video
Utenti
Chi Siamo
Contattaci
Username:
Password:
Login
Registrati ora!
Recupera Password
Home Page
Stanze Forum
App. WinForms / WPF .NET
Polling su una tabella
giovedì 22 febbraio 2007 - 11.57
Elenco Threads
Stanze Forum
Aggiungi ai Preferiti
Cerca nel forum
sasa72
Profilo
| Newbie
23
messaggi | Data Invio:
gio 22 feb 2007 - 11:57
Ciao,
devo fare un'applicazione in vb.net che sia un servizio windows e che deve stare in polling su una tabella di mysql:
quando viene inserito un record in questa tabella (ce ne sarà sempre solo uno) devo fare determinate operazioni per riscrivere poi il risultato su un'altra tabella.
Ho visto che si puo' creare con vb.net un'applicazione che sia un servizio e da quello che ho capito dovro' mettere cio' che devo eseguire nel metodo onstart.
Qualcuno puo' darmi un suggerimento su come fare il polling sulla tabella?
Grazie
Saluti
Jumpa
Profilo
| Junior Member
176
messaggi | Data Invio:
gio 22 feb 2007 - 13:27
io farei partire un timer che fa l'interrogazione ogni N minuti
-------------------------
Follow the White Rabbit...
http://www.jumpa.org
-------------------------
sasa72
Profilo
| Newbie
23
messaggi | Data Invio:
gio 22 feb 2007 - 14:37
mi puoi fare un esempio?
non so minimamente da dove iniziare oppure se c'e' qualche link dove posso vedere..
Grazie
Jumpa
Profilo
| Junior Member
176
messaggi | Data Invio:
gio 22 feb 2007 - 16:01
Un esempio in c# estratto dalla guida di VS,
puoi tradulo facilmente in vb.net
vedi all'inizio istanzia un nuovo oggetto di tipo timer,
poi crea la funzione per gestirne il tick
guarda un po se ti è utile?
cmq se guardi nella guida di VB dovresti avere un esempio analogo per visualbasi.net!
public class Class1 {
static System.Windows.Forms.Timer myTimer = new System.Windows.Forms.Timer();
static int alarmCounter = 1;
static bool exitFlag = false;
// This is the method to run when the timer is raised.
private static void TimerEventProcessor(Object myObject,
EventArgs myEventArgs) {
myTimer.Stop();
// Displays a message box asking whether to continue running the timer.
if(MessageBox.Show("Continue running?", "Count is: " + alarmCounter,
MessageBoxButtons.YesNo) == DialogResult.Yes) {
// Restarts the timer and increments the counter.
alarmCounter +=1;
myTimer.Enabled = true;
}
else {
// Stops the timer.
exitFlag = true;
}
}
public static int Main() {
/* Adds the event and the event handler for the method that will
process the timer event to the timer. */
myTimer.Tick += new EventHandler(TimerEventProcessor);
// Sets the timer interval to 5 seconds.
myTimer.Interval = 5000;
myTimer.Start();
// Runs the timer, and raises the event.
while(exitFlag == false) {
// Processes all the events in the queue.
Application.DoEvents();
}
return 0;
}
}
-------------------------
Follow the White Rabbit...
http://www.jumpa.org
-------------------------
sasa72
Profilo
| Newbie
23
messaggi | Data Invio:
gio 22 feb 2007 - 19:33
grazie
adesso lo provo.
Saluti
Torna su
Stanze Forum
Elenco Threads
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?
Dopo esserti registrato potrai chiedere
aiuto sul nostro
Forum
oppure aiutare gli altri
Consulta le
Stanze
disponibili.
Registrati ora !