> 文章列表 > BarTender.Application COM 多次调用引发后台进程数不断增加的问题

BarTender.Application COM 多次调用引发后台进程数不断增加的问题

BarTender.Application COM 多次调用引发后台进程数不断增加的问题

引用文章方法测试,目前未发现问题.

Closing Instance Of Bartender – BarTender Support Portal (seagullscientific.com)

Closing Instance Of Bartender

FollowFollowed by one person

Legacy Poster

  • 9 years ago

Hello again,

I've got BarTender automating along nicely.......but have just discovered a problem when it comes to closing the instance of bartender.

My previous post http://forums.seagullscientific.com/index.php?/topic/2222-automating-label-printing-from-access-db-random-printers/

Shows how i get to the stage of printing out the labels i require, it's just that in the task manager, the number of bartender.exe instances keep adding up and up and up each time i use my access database to print a label.

I'm using bt.quit after each label is printed, but the bartender.exe instance is still in the task manager, and on our XP machines, this is causing them to slow down and grind to a halt.

Is there something i'm missing?

Regards

Ryan

0

 12

Comments

12 comments

Sort by 

  • Legacy Poster

    • 9 years ago

    when youve finished printing your labels make sure you are stopping the BT engine, so assuming your engine object is labelled as "engine" the following may help you  out 

                                        If engine.IsAlive Then

                                            engine.Stop(SaveOptions.DoNotSaveChanges)

                                        End If

    0

  • Legacy Poster

    • 9 years ago

    Hello,

    thanks for your reply, but i'm not sure i understand the engine part. The process that runs and won't stop is bartender.exe

    My code to initialize is

    Dim btApp As BarTender.Application

    Set btApp = CreateObject("BarTender.Application")

    Is this what you need to help out?

    Regards

    Ryan

    0

  • Legacy Poster

    • 9 years ago

    Please also note that Print Station also uses a bartender.exe process so killing all instances wouldn't be a feasible solution as we need Print Station open and running too

    Regards

    Ryan

    0

  • Legacy Poster

    • 9 years ago

    sorry i should of asked but what version of bartender are you running? as that code I supplied was for use with bartender 10 SR4 SDK integration

    Cheers,

    Scott

    0

  • Legacy Poster

    • 9 years ago

    Using Bartender 10.1 sr1

    Controlling access with VB

    Regards

    Ryan

    0

  • Legacy Poster

    • 9 years ago

    ah right, apologies ive used vb.net in 3.5 framework for my solutions. the only thing i could think is to look for a quit or close command against the object you are creating maybe? and see where that ends up. other than that I cannot really offer any more assistance sorry. 

    one thing are you using the SDK because i could provide you with the function we use in .NET to manage to instance closure after printing of labels?

    Cheers,

    Scott

    0

  • Legacy Poster

    • 9 years ago

    No i'm not i'm afraid, I dont completely understand it and we have a number of different Windows OS kicking about so it's a biut of a mission getting everything to work on each machine.

    If you have an easier guide then the white paper i'd be interested in that?

    Regards

    Ryan

    0

  • Legacy Poster

    • 9 years ago

    Like I said this is .NET based integration of the BT10 SR4 SDK but I hope it is of some use to you in finding a workable result.

    it might be worth taking another look at the SDK with the code below as it does handle the disposal of the BT instance when youve finished printing.

    'Bartender10.0'get a new bartender engine instantiated
    engine = New Engine(True)'check format has been cleared and clear if still in use.
    If format IsNot Nothing Thenformat.Close(SaveOptions.DoNotSaveChanges)
    End If'load the label into memory.
    format = engine.Documents.Open(Label.LabelDirectory & Label.LabelFormat)' Get the printer and assign it to the format.
    format.PrintSetup.PrinterName = PrinterNameDim waitForCompletionTimeout As Integer = 10000 ' 10 seconds
    Dim oleDB As New Seagull.BarTender.Print.Database.OLEDB(Label.Database)
    oleDB.UserID = Label.DBUsername
    oleDB.SetPassword(Label.DBPassword)If format.DatabaseConnections.Count > 0 Thenformat.DatabaseConnections.SetDatabaseConnection(oleDB)
    End If' Retrieve the QueryPrompts object.
    Dim queryprompts As Database.QueryPrompts = format.DatabaseConnections.QueryPrompts' set the name queryprompt to the order number value.
    queryprompts("ID").Value = BoxToPrint.ToStringDim messages As Messages = Nothing
    format.Print(strApp, waitForCompletionTimeout, messages)Dim messageString As String = Constants.vbLf + Constants.vbLf & "Messages:"For Each message As Seagull.BarTender.Print.Message In messagesmessageString &= Constants.vbLf + Constants.vbLf + message.Text
    Next messageIf engine.IsAlive Thenengine.Stop(SaveOptions.DoNotSaveChanges)
    End If

    Cheers,

    Scott

    0

  • Legacy Poster

    • 9 years ago

    Hello again,

    I'm still struggling to find a solution to my original post i'm afraid

    has anyone got any more input?

    Regards

    Ryan

    0

  • Legacy Poster

    • 9 years ago

    Hello again,

    I'm still struggling to find a solution to my original post i'm afraid

    has anyone got any more input?

    Regards

    Ryan

    Hey Ryan,

    New to this forum, however I've conjured up this little beauty in VBScript:

    strComputer = "."
    strProcessToKill = "bartend.exe" SET objWMIService = GETOBJECT("winmgmts:" _& "{impersonationLevel=impersonate}!\\\\" _ & strComputer & "\\root\\cimv2") SET colProcess = objWMIService.ExecQuery _("Select * from Win32_Process Where Name = '" & strProcessToKill & "'")count = 0
    FOR EACH objProcess in colProcessobjProcess.Terminate()count = count + 1
    NEXT 
    

    0

  • Legacy Poster

    • 9 years ago

    Hello,

    Sorry for the delay, i've been off work for a couple of days

    Thanks for your reply, where would this script go? Also, would this kill all instances of BarTender as we also use PrintStation on the same machines so i'm concerned this would have an effect on that too?

    Regards

    Ryan

    0

  • Legacy Poster

    • 7 years ago

    Hello.

    I'm aware this post is old, but for future reference...

    After you do:

    btFormat.Close(BarTender.BtSaveOptions.btDoNotSaveChanges)
    btApp.Quit()
    

    Add line:  

    System.Runtime.InteropServices.Marshal.ReleaseComObject(btApp)
    

    And that will chase down any leftover bartend.exe processes.

    Regards,

    0

Please sign in to leave a comment.

btFormat.Close(BarTender.BtSaveOptions.btDoNotSaveChanges)
btApp.Quit()

Add line:  

System.Runtime.InteropServices.Marshal.ReleaseComObject(btApp)