dotConnect for MySQL Documentation
Devart.Common Namespace / DbDump Class / BeginRestore Method / BeginRestore(String) Method
The name of the file to load the script from.
Example

In This Topic
    BeginRestore(String) Method
    In This Topic
    Starts an asynchronous invocation of a Restore(String) method.
    Syntax
    'Declaration
     
    Public Overloads Function BeginRestore( _
       ByVal fileName As String _
    ) As IAsyncResult
    public IAsyncResult BeginRestore( 
       string fileName
    )

    Parameters

    fileName
    The name of the file to load the script from.

    Return Value

    An System.IAsyncResult interface that represents the asynchronous operation started by calling this method.
    Remarks

    BeginRestore(String) method enables you to perform a restore operation without having current thread blocked. In other words, your program can continue execution while the restore operation runs in background so you do not have to wait for it.

    To start the restore operation, you have to call BeginRestore(String) method, which in turn invokes appropriate actions in another thread. Return value of this method must be assigned to an System.IAsyncResult object. After executing this method, the program flow continues.

    When you are ready to finish the backup operation, call EndRestore. If at the moment you call this function the restore operation has not yet been finished, application stops and waits till the function returns.

    Example
    This sample demonstrates performing async backup and restore operations.
    public void DumpIt(MySqlConnection myConnection) {
            myConnection.Open();
            MySqlDump mySqlDump = new MySqlDump();
            mySqlDump.Connection = myConnection;
            myConnection.Database = "Test";
            mySqlDump.IncludeDrop = true;
            mySqlDump.GenerateHeader = true;
            mySqlDump.Tables = "Dept;Emp";
            IAsyncResult myResult = mySqlDump.BeginBackup("d:\\tmp\\mysqldump.dmp");
            while (!myResult.IsCompleted) {
                    Console.Write(".");
                    //Perform here any operation you need
            }
            mySqlDump.EndBackup(myResult);
            Console.WriteLine("Dumped.");
            myConnection.Close();
    }
    
    public void UnDumpIt(MySqlConnection myConnection) {
            myConnection.Open();
            MySqlDump mySqlDump = new MySqlDump();
    
            mySqlDump.Connection = myConnection;
            myConnection.Database = "Test";
            IAsyncResult myResult = mySqlDump.BeginRestore("d:\\tmp\\mysqldump.dmp");
            while (!myResult.IsCompleted)
            {
                    Console.Write(".");
                    //Perform here any operation you need
            }
            mySqlDump.EndRestore(myResult);
            Console.WriteLine("Restored.");
            myConnection.Close();
    }
    Public Sub DumpIt(myConnection As MySqlConnection)
            myConnection.Open()
            Dim mySqlDump As New MySqlDump()
            mySqlDump.Connection = myConnection
            myConnection.Database = "Test"
            mySqlDump.IncludeDrop = True
            mySqlDump.GenerateHeader = True
            mySqlDump.Tables = "Dept;Emp"
            Dim myResult As IAsyncResult = mySqlDump.BeginBackup("d:\tmp\mysqldump.dmp")
            While Not myResult.IsCompleted
                    'Perform here any operation you need
                    Console.Write(".")
            End While
            mySqlDump.EndBackup(myResult)
            Console.WriteLine("Dumped.")
            myConnection.Close()
    End Sub
    
    Public Sub UnDumpIt(myConnection As MySqlConnection)
            myConnection.Open()
            Dim mySqlDump As New MySqlDump()
    
            mySqlDump.Connection = myConnection
            myConnection.Database = "Test"
            Dim myResult As IAsyncResult = mySqlDump.BeginRestore("d:\tmp\mysqldump.dmp")
            While Not myResult.IsCompleted
                    'Perform here any operation you need
                    Console.Write(".")
            End While
            mySqlDump.EndRestore(myResult)
            Console.WriteLine("Restored.")
            myConnection.Close()
    End Sub
    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also