Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

SMO Backup event PercentCompleteEventHandler not fired Expand / Collapse
Author
Message
Posted Monday, October 10, 2011 2:27 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Wednesday, August 27, 2014 12:37 AM
Points: 2,728, Visits: 267
Hi,

When I run this code, the event PercentCompleteEventHandler (Backup_PercentComplete); never fired.

Then event ServerMessageEventHandler(Backup_Complete) is fired

when the backup is complete.

The backup operation run Ok and without errors.

Runnig with vs 2008 and sql server 2008 r2 RTM

Objects SMO version 10.0.0.0

Any ideas?

The code:

using System;
using System.Data;
using System.Collections;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;


class Program
{

static void Main(string[] args)
{
BackupDeviceItem bdi = new BackupDeviceItem(@"c:\temp\MyDB.bak", DeviceType.File);
Backup bu = new Backup( );
bu.Database ="MyDB";
bu.Devices.Add(bdi);
bu.Initialize =true;

bu.PercentCompleteNotification = 10;

// add percent complete and complete event handlers
bu.PercentComplete += new PercentCompleteEventHandler(Backup_PercentComplete);
bu.Complete += new ServerMessageEventHandler(Backup_Complete);


Server server = new Server("localhost");
bu.SqlBackup(server);

Console.WriteLine(Environment.NewLine + "Press any key to continue.");

Console.ReadKey( );
}



protected static void Backup_PercentComplete( object sender, PercentCompleteEventArgs e)
{

Console.WriteLine(Environment.NewLine + e.Percent + "% processed.");
}



protected static void Backup_Complete(object sender, ServerMessageEventArgs e)
{
Console.WriteLine(Environment.NewLine + e.ToString( ));
}

}




Post #1187762
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse