Zum Hauptinhalt gehen

Suche

Suche

Close Bartend

Kommentare

2 Kommentare

  • Avatar
    Legacy Poster

    Hum I've done this in version 10.4 but based on what I read it should be working in 9.4.

    First you should take out of your loop the creating of your BarTender.ApplicationClass.

    Then you can close it only when the loop is done.

     

    In your loop you should create and destroy your btFormat. So your code should look like this :

     

    //Launch bartender files
    string excPath = System.IO.Path.GetDirectoryName(Application.ExecutablePath);

    BarTender.ApplicationClass btApp;
    BarTender.Format btFormat;
    BarTender.Messages btMsgs;

     

    btApp = new BarTender.ApplicationClass();

    //Loop through array of all the files.

    foreach (string for_string in string_array_bt)
    {
    string temp_path = excPath + "\\" + str_FileNames + "\\" + for_string+".btw";
    btFormat = btApp.Formats.Open(temp_path, false, "");

    //Pulls Data from DataGridView
    btFormat.Print(temp_path, false, 1, out btMsgs);
    btFormat.Close();
    Debug.WriteLine(temp_path);

    MessageBox.Show("Sent Job " + for_string + " to printer";

    }

     

    btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges); 

    0
  • Avatar
    Ian Cummings
    Moderator
    It should be noted that .NET can hold on to the BarTender object even after the Quit() method has been called.  To force .NET to release the object, make the following call:
     
    System.Runtime.InteropServices.Marshal.ReleaseComObject(btApp)
     
    Make the call after calling Quit and before you set the BarTender instance object to Nothing.  Check the Windows task manager to see if the "bartend.exe" process is removed and that memory is released to the system.
    1

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.