I am creating a class that wraps around google calender so i can talk with my good calender through my application.
In my test form I have a button click event that has the codeCode:Imports Google Imports Google.GData.Calendar Imports Google.GData.Client Imports Google.GData.Extensions Public Class gcalwrapper Private _serviceName As String Private myService As CalendarService Protected Property servicename() As String Get Return _serviceName End Get Set(ByVal value As String) _serviceName = value End Set End Property Public Event AppointmentComingUp() Public Sub New() If String.IsNullOrEmpty(servicename) Then myService = New CalendarService("CalendarService") Else myService = New CalendarService(servicename) End If End Sub Public Sub New(ByVal sname As String) servicename = sname myService = New CalendarService(servicename) End Sub Public Sub startTimeMonitor() RaiseEvent AppointmentComingUp() End Sub End Class
and the appropriate sub that handles the addressof; in that sub I have a simple msgbox.Code:Dim gc As New gcalwrapper("Testservice") AddHandler gc.AppointmentComingUp, AddressOf gc_AppointmentComingUp gc.setCrediantials("affan05", "***") gc.startTimeMonitor()
THIS IS MY FIRST TIME WITH EVENTS, so i decided to go with addhandler since MSDN told me it would be better in my situation. with handles/withevents i'd have to declare a public withevetns variable.
IMO I like this way the best even though i dont know delegates yet.
ANYWAY. so my whole plan is to creatte like a background thread (Backgroundworker) in my initial form load. I want this to have a infinte timer that runs and retreives events and does a check whether an event is cmoing up in the next 30 minutes. all this is gonna be taking place in the sub startTimeMonitor thats in the class, and if something happens then it raises the event.
finally to my question. I have a MDI form with chid forms that get opened and closed (not hidden but closed). Would it be wise to create a bgworker in my MDI form class? that way it would run for ever, even with other forms opening and closing?
and what about the associating subroutine? Would that also go in my MDI form?


Reply With Quote