Polling su una tabella

giovedì 22 febbraio 2007 - 11.57

sasa72 Profilo | Newbie

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

io farei partire un timer che fa l'interrogazione ogni N minuti
-------------------------
Follow the White Rabbit...

http://www.jumpa.org
-------------------------

sasa72 Profilo | Newbie

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

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

grazie
adesso lo provo.
Saluti
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 !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5