.net - Handle events in another class -


I'm trying to move some code to some class files to clear my code. An area with which I'm having trouble is reporting the progress of events between the work and the object of a progress bar.

I think the event work has to be put in the new category, but they need to update the progress bar on the calling form? Can Event Class \ object back instead of handlers Update

The current form all code is:

  function DoRestore (ByVal SQLServer string as string as ByVal BackupFilePath , ByVal DatabaseName as string) dim server = new server ServerkConnectionContextkApplicationName (as SQLServer) = Application.ProductName dim race restore = new restore (in) dim DataTable res.Devices.AddDevice (BackupFilePath, DT as DeviceType.File) Dt = res.ReadFileList (server) res.Database = DatabaseName res.PercentCompleteNotifi Cation = 1 AddHandler res.PercentComplete, Address Off RestoreProgressEventHandler AddHandler res.Complete, AddressOf Restore Complete EventHandler Res.SqlRestoreAsync (server) res.AsyncStatus.ExecutionStatus = ExecutionStatus.InProgress application. DoEvents () Ending while Expiration Function Private Function RestoreProgressEventHandler (ByVal this object as a result, as ByVal e PercentCompleteEventArgs) 'update progress bar (e.Percent) end function Private sub RestoreComp leteEventHandler (ByVal as the object, as ByVal e Microsoft.SqlServer.Management.Common.ServerMessageEventArgs)' Signal Completion via End Sub   

The area used:

  DoRestore (SQLServer, "C: \ SQLBACKUP.bak", DatabaseName)    

should you define an event in your class and handle updates of the progress bar in the form (assuming WinForms?) - this issue is that the class relates to supporting something There should be no concept of progress bars:

Define the incident in the category:

  Public Event Report Progress (East Bilateral progress as Ank)   

The time required to backup extend this event:

  RaiseEvent ReportProgress (value)   

In the calling code you either need

  • Define a class using with Events :

     < code> backup personal Bakavent backup as Class   

    and then act on this event:

      progress as Private sub backup _ReportProgress (integer) Backup backup Report Progress Debug WrightLine ("Progress:" + Progress.ToString) End Sub    
  • Or Manually Add a Handler:

      Personal Debug Reporter Progress Handler (progress as integer) Debug. WrightLine ("progress handler:" + progression.tostring) Add End Addendum Backup. Report Progress, Address Backup_ReportProgressHandler      

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -