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
Posted Monday, October 10, 2011 2:27 AM


Group: General Forum Members
Last Login: 2 days ago @ 2:46 AM
Points: 2,897, Visits: 285

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

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.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");

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