B
Bre-x
Guest
Hello,
I have created a service it works well. I am concern about how much memory is using
Windows 10 : 35MB Is this ok? Am I missing something?
Please advice
John
Imports System
Imports System.IO
Imports System.Timers
Imports System.Net.Mail
Public Class sapp
Dim TimerX As System.Timers.Timer = New System.Timers.Timer()
Dim is_run_time As Date = Nothing
Protected Overrides Sub OnStart(ByVal args() As String)
is_run_time = "1:55:00 PM"
AddHandler TimerX.Elapsed, New ElapsedEventHandler(AddressOf OnTimedEvent)
With TimerX
.Interval = 1000
.Enabled = True
End With
End Sub
Protected Overrides Sub OnStop()
With TimerX
.Enabled = False
End With
End Sub
Private Sub OnTimedEvent(ByVal source As Object, ByVal e As ElapsedEventArgs)
If Now.ToString("T") = is_run_time Then
print_then_email()
End If
End Sub
Private Sub print_then_email()
Dim the_pdf As String = "C:\sco_apps\pdf\Service_PDF.pdf"
Dim frm As New fprint_01
Dim mail As MailMessage = New MailMessage()
Dim client As SmtpClient = New SmtpClient("server")
'Print
frm.qcn_mainTableAdapter.Fill(frm.ds_main.qcn_main)
frm.ReportViewer1.RefreshReport()
Dim byteViewer As Byte() = frm.ReportViewer1.LocalReport.Render("PDF")
Dim newFile As New System.IO.FileStream(the_pdf, System.IO.FileMode.Create)
newFile.Write(byteViewer, 0, byteViewer.Length)
newFile.Close()
'Mail
mail.From = New MailAddress("email")
mail.To.Add("email")
mail.Subject = "Test Email From Service"
mail.Body = "This is a test email sent by my .net windows service."
mail.Attachments.Add(New Attachment(the_pdf))
client.Port = 25
client.Credentials = New System.Net.NetworkCredential("email", "pass")
client.Send(mail)
End Sub
End Class
Continue reading...
I have created a service it works well. I am concern about how much memory is using
Windows 10 : 35MB Is this ok? Am I missing something?
Please advice
John
Imports System
Imports System.IO
Imports System.Timers
Imports System.Net.Mail
Public Class sapp
Dim TimerX As System.Timers.Timer = New System.Timers.Timer()
Dim is_run_time As Date = Nothing
Protected Overrides Sub OnStart(ByVal args() As String)
is_run_time = "1:55:00 PM"
AddHandler TimerX.Elapsed, New ElapsedEventHandler(AddressOf OnTimedEvent)
With TimerX
.Interval = 1000
.Enabled = True
End With
End Sub
Protected Overrides Sub OnStop()
With TimerX
.Enabled = False
End With
End Sub
Private Sub OnTimedEvent(ByVal source As Object, ByVal e As ElapsedEventArgs)
If Now.ToString("T") = is_run_time Then
print_then_email()
End If
End Sub
Private Sub print_then_email()
Dim the_pdf As String = "C:\sco_apps\pdf\Service_PDF.pdf"
Dim frm As New fprint_01
Dim mail As MailMessage = New MailMessage()
Dim client As SmtpClient = New SmtpClient("server")
frm.qcn_mainTableAdapter.Fill(frm.ds_main.qcn_main)
frm.ReportViewer1.RefreshReport()
Dim byteViewer As Byte() = frm.ReportViewer1.LocalReport.Render("PDF")
Dim newFile As New System.IO.FileStream(the_pdf, System.IO.FileMode.Create)
newFile.Write(byteViewer, 0, byteViewer.Length)
newFile.Close()
mail.From = New MailAddress("email")
mail.To.Add("email")
mail.Subject = "Test Email From Service"
mail.Body = "This is a test email sent by my .net windows service."
mail.Attachments.Add(New Attachment(the_pdf))
client.Port = 25
client.Credentials = New System.Net.NetworkCredential("email", "pass")
client.Send(mail)
End Sub
End Class
Continue reading...