Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros entornos y lenguajes > .NET
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 10-01-2008
Kastor Kastor is offline
Registrado
 
Registrado: jun 2007
Posts: 6
Poder: 0
Kastor Va por buen camino
gracias muchachos, probare con lo que me dicen y les cuento.


tengo otro servicio en Visual y si funciona el Timer, pero es un system.timers.Timer, pero no se como diablos implementarlo en Delphi.
Responder Con Cita
  #2  
Antiguo 21-01-2008
Kastor Kastor is offline
Registrado
 
Registrado: jun 2007
Posts: 6
Poder: 0
Kastor Va por buen camino
Unhappy

me he complicado demasiado al parecer.

busque todo lo referente al SetTimer y temporizadores, pero nada me resulta con buen termino.

para empezar la funcion tiene STDCALL, pero me envia un error de:
"Procedure definition must be ILCODE calling convention"

probe con {$UNSAFECODE ON}, pero solo funciono en la declaracion de la funcion.

esto es lo que he implementado:

Código Delphi [-]
procedure TWindowsService.TimerProc( wnd : HWND;  msg : UINT; iTimerID : UINT; dwTime : DWORD );
begin

//TimerAction;

try
    archivo.Add('TimerAction');
    archivo.SaveToFile('C:\un_texto.txt');
except
  on e: exception do begin
    archivo.Add(e.ToString);
  archivo.SaveToFile('c:\un_texto_Error.txt');

  end;
end;
end;


en el evento Onstart
Código Delphi [-]
procedure TWindowsService.OnStart(args: array of string);

begin
  inherited;
  try
    SetTimer(NULL,0,3000, @timerproc );
  except
    on e: exception do begin
      archivo.Add(e.ToString);
      archivo.SaveToFile('c:\error.txt');
    end;
  end;
end;

para poder usar la variable NULL es necesario agregar unit "variants"

me da el siguiente error:
"Borland.Vcl.EVariantTypeCastError: Invalid variant type conversion of Null variant into LongWord
at Borland.Vcl.VariantHelper.VarTypeCastError(Int32 ASourceType, Int32 ADestType)
at Borland.Vcl.VariantHelper.HandleExceptionTranslation(Exception E, Int32 AFirstType, Int32 ASecondType)
at Borland.Vcl.VariantHelper.UnhandledConversionException(Exception E, Int32 OldType, Int32 NewType)
at Borland.Vcl.VariantHelper.ToUInt32(Object AObject)
at Service.TWindowsService.OnStart(String[] args)
"

este link tambien lo revise
http://www.clubdelphi.com/foros/showthread.php?t=44155
(que ademas tiene unas frases para el Oscar, que me rei mucho )



la ultima pregunta es, en que lugar debo llamar a KillTimer, creo que al evento:
OnStop, OnPause, OnShutDown ???

gracias camaradas.
Responder Con Cita
  #3  
Antiguo 24-01-2008
Kastor Kastor is offline
Registrado
 
Registrado: jun 2007
Posts: 6
Poder: 0
Kastor Va por buen camino
Thumbs up Solución

gracias a san google pude implementar el Timer de bajo nivel.

Código Delphi [-]
uses
System.Timers

tTimer:System.Timers.Timer;

procedure TimerAction(Sender: TObject; e: System.Timers.ElapsedEventArgs);


constructor TWindowsService.Create;
begin
  inherited Create;

   ttimer:=System.Timers.Timer.Create;
  //la proxima linea soluciono un error que genera .NET
   include(tTimer.Elapsed, TimerAction);

   ttimer.Interval:=300000;//cada 5 minutos
   ttimer.Enabled:=true;

 
end;

procedure TWindowsService.TimerAction(Sender: TObject; e: System.Timers.ElapsedEventArgs);
begin
   //escribir la accion que necesitas, se llamara cada X milisegundos del
   //Timer
    
end;


el error solucionado por Include es:

v.ServerValidate := CustomValidator1_ServerValidate ;


But in .Net world this causes an error:


'read/write not allowed for CLR events. Use Include/Exclude procedure
(E2298)Multicast events cannot be assigned to or read from traditional
Delphi read/write events. Use Include/Exclude to add or remove methods' .

la explicacion y solucion detallada la encuentran en :
http://www.delphi3000.com/printartic...ArticleID=4434



saludos
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Como arrancar o parara un servicio en funcion de otro servicio ?? QuarkBcn API de Windows 12 15-06-2011 14:46:11
Instalacion Firebird en D2005 cesarsoftware Conexión con bases de datos 1 27-11-2006 21:24:44
ORD? diferente resultado en D7 k en D2005????? arantzal Varios 0 24-06-2005 09:39:17
Aplicaciones MDI en D2005 y .NET adcoma .NET 2 13-04-2005 16:39:51
Ayuda de D2005 bpesoj Varios 0 25-12-2004 11:41:42


La franja horaria es GMT +2. Ahora son las 18:39:46.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi