{"id":258,"date":"2009-05-25T20:43:16","date_gmt":"2009-05-25T20:43:16","guid":{"rendered":"http:\/\/www.btb4net.com\/borenblog\/?p=258"},"modified":"2014-04-17T09:22:28","modified_gmt":"2014-04-17T09:22:28","slug":"running-procces-in-background","status":"publish","type":"post","link":"https:\/\/www.btb4net.com\/borenblog\/running-procces-in-background\/","title":{"rendered":"Running proccess in background"},"content":{"rendered":"<p>VB.NET class for running process\/application as background thread:<\/p>\n<p><code>Public Class Shell<br \/>\n\t&nbsp; &nbsp;<br \/>\n\t&nbsp; &nbsp;Private Process1 As Process = New Process()<br \/>\n\t&nbsp; &nbsp;Sub New()<br \/>\n\t&nbsp; &nbsp;<br \/>\n\t&nbsp; &nbsp;End Sub<br \/>\n\t&nbsp; &nbsp;<br \/>\n\t&nbsp; &nbsp;Public ReadOnly Property Active() As Boolean<br \/>\n\t&nbsp; &nbsp; &nbsp; Get<br \/>\n\t&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Return Process1.HasExited<br \/>\n\t&nbsp; &nbsp; &nbsp; End Get<br \/>\n\t&nbsp; &nbsp;End Property<br \/>\n\t&nbsp; &nbsp;<br \/>\n\t&nbsp; &nbsp;Public Sub Run(ByVal sProcessPath As String, ByVal sArguments As String)<br \/>\n\t&nbsp; &nbsp; &nbsp; Process1.StartInfo.FileName = sProcessPath<br \/>\n\t&nbsp; &nbsp; &nbsp; Process1.StartInfo.WindowStyle = ProcessWindowStyle.Minimized<br \/>\n\t&nbsp; &nbsp; &nbsp; Process1.StartInfo.CreateNoWindow = False<br \/>\n\t&nbsp; &nbsp; &nbsp; Process1.StartInfo.UseShellExecute = True<br \/>\n\t&nbsp; &nbsp; &nbsp; Process1.EnableRaisingEvents = True<br \/>\n\t&nbsp; &nbsp; &nbsp; Process1.StartInfo.Arguments = sArguments<br \/>\n\t&nbsp; &nbsp; &nbsp; Try<br \/>\n\t&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#39;Start Process <br \/>\n\t&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Process1.Start()<br \/>\n\t&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Wait()<br \/>\n\t&nbsp; &nbsp; &nbsp; Catch ex As Exception<br \/>\n\t&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MsgBox(ex.Message)<br \/>\n\t&nbsp; &nbsp; &nbsp; Finally<br \/>\n\t&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Process1.Close()<br \/>\n\t&nbsp; &nbsp; &nbsp; End Try<br \/>\n\t&nbsp; &nbsp;End Sub<br \/>\n\t&nbsp; &nbsp;<br \/>\n\t&nbsp; &nbsp;Private Sub Wait()<br \/>\n\t&nbsp; &nbsp; &nbsp; If Not Process1.HasExited Then<br \/>\n\t&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.Threading.Thread.Sleep(1000)<br \/>\n\t&nbsp; &nbsp; &nbsp; End If<br \/>\n\t&nbsp; &nbsp;End Sub<br \/>\n\tEnd Class<\/code><\/p>\n<p>Example for transparent printing txt file:<\/p>\n<p><code>Dim sproc As New Shell<br \/>\n\tsproc.Run(&quot;notepad&quot;, &quot; \/p c:\\test\\example.txt&quot; )<\/code><\/p>\n<p>Example for transparent printing pdf &nbsp;file with FoxitReader :<\/p>\n<p><code>Dim pdfAppPath as String = String.Empty<br \/>\n\tDim progamsfolder As String = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)<br \/>\n\tIf File.Exists(progamsfolder &amp; &quot;\\Foxit\\FoxitReader.exe&quot;) Then pdfAppPath = progamsfolder &amp; &quot;\\Foxit\\FoxitReader.exe&quot;<br \/>\n\t&nbsp; &nbsp;<br \/>\n\tDim sproc As New Shell<br \/>\n\tsproc.Run(pdfAppPath, &quot; \/p c:\\test\\example.pdf&quot;)<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>VB.NET class for running process\/application as background thread: Public Class Shell &nbsp; &nbsp; &nbsp; &nbsp;Private Process1 As Process = New Process() &nbsp; &nbsp;Sub New() &nbsp; &nbsp; &nbsp; &nbsp;End Sub &nbsp; &nbsp; &nbsp; &nbsp;Public ReadOnly Property Active() As Boolean &nbsp; &nbsp; &nbsp; Get &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Return Process1.HasExited &nbsp; &nbsp; &nbsp; End Get &nbsp; &nbsp;End [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[25],"tags":[],"class_list":["post-258","post","type-post","status-publish","format-standard","hentry","category-vb-net"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Running proccess in background - Branislav Pavlovic<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.btb4net.com\/borenblog\/running-procces-in-background\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Running proccess in background - Branislav Pavlovic\" \/>\n<meta property=\"og:description\" content=\"VB.NET class for running process\/application as background thread: Public Class Shell &nbsp; &nbsp; &nbsp; &nbsp;Private Process1 As Process = New Process() &nbsp; &nbsp;Sub New() &nbsp; &nbsp; &nbsp; &nbsp;End Sub &nbsp; &nbsp; &nbsp; &nbsp;Public ReadOnly Property Active() As Boolean &nbsp; &nbsp; &nbsp; Get &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Return Process1.HasExited &nbsp; &nbsp; &nbsp; End Get &nbsp; &nbsp;End [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.btb4net.com\/borenblog\/running-procces-in-background\/\" \/>\n<meta property=\"og:site_name\" content=\"Branislav Pavlovic\" \/>\n<meta property=\"article:published_time\" content=\"2009-05-25T20:43:16+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-04-17T09:22:28+00:00\" \/>\n<meta name=\"author\" content=\"Pavlovi\u0107 Branislav\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Pavlovi\u0107 Branislav\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.btb4net.com\/borenblog\/running-procces-in-background\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.btb4net.com\/borenblog\/running-procces-in-background\/\"},\"author\":{\"name\":\"Pavlovi\u0107 Branislav\",\"@id\":\"https:\/\/www.btb4net.com\/borenblog\/#\/schema\/person\/1b2f711186b5e6d2f949b93ce659fa28\"},\"headline\":\"Running proccess in background\",\"datePublished\":\"2009-05-25T20:43:16+00:00\",\"dateModified\":\"2014-04-17T09:22:28+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.btb4net.com\/borenblog\/running-procces-in-background\/\"},\"wordCount\":29,\"articleSection\":[\"VB.NET\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.btb4net.com\/borenblog\/running-procces-in-background\/\",\"url\":\"https:\/\/www.btb4net.com\/borenblog\/running-procces-in-background\/\",\"name\":\"Running proccess in background - Branislav Pavlovic\",\"isPartOf\":{\"@id\":\"https:\/\/www.btb4net.com\/borenblog\/#website\"},\"datePublished\":\"2009-05-25T20:43:16+00:00\",\"dateModified\":\"2014-04-17T09:22:28+00:00\",\"author\":{\"@id\":\"https:\/\/www.btb4net.com\/borenblog\/#\/schema\/person\/1b2f711186b5e6d2f949b93ce659fa28\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.btb4net.com\/borenblog\/running-procces-in-background\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.btb4net.com\/borenblog\/running-procces-in-background\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.btb4net.com\/borenblog\/running-procces-in-background\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.btb4net.com\/borenblog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Running proccess in background\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.btb4net.com\/borenblog\/#website\",\"url\":\"https:\/\/www.btb4net.com\/borenblog\/\",\"name\":\"Branislav Pavlovic\",\"description\":\"My Portfolio\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.btb4net.com\/borenblog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.btb4net.com\/borenblog\/#\/schema\/person\/1b2f711186b5e6d2f949b93ce659fa28\",\"name\":\"Pavlovi\u0107 Branislav\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.btb4net.com\/borenblog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/62c17a10b5883b6f49efea84199811ef?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/62c17a10b5883b6f49efea84199811ef?s=96&d=mm&r=g\",\"caption\":\"Pavlovi\u0107 Branislav\"},\"url\":\"https:\/\/www.btb4net.com\/borenblog\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Running proccess in background - Branislav Pavlovic","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.btb4net.com\/borenblog\/running-procces-in-background\/","og_locale":"en_US","og_type":"article","og_title":"Running proccess in background - Branislav Pavlovic","og_description":"VB.NET class for running process\/application as background thread: Public Class Shell &nbsp; &nbsp; &nbsp; &nbsp;Private Process1 As Process = New Process() &nbsp; &nbsp;Sub New() &nbsp; &nbsp; &nbsp; &nbsp;End Sub &nbsp; &nbsp; &nbsp; &nbsp;Public ReadOnly Property Active() As Boolean &nbsp; &nbsp; &nbsp; Get &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Return Process1.HasExited &nbsp; &nbsp; &nbsp; End Get &nbsp; &nbsp;End [&hellip;]","og_url":"https:\/\/www.btb4net.com\/borenblog\/running-procces-in-background\/","og_site_name":"Branislav Pavlovic","article_published_time":"2009-05-25T20:43:16+00:00","article_modified_time":"2014-04-17T09:22:28+00:00","author":"Pavlovi\u0107 Branislav","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Pavlovi\u0107 Branislav","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.btb4net.com\/borenblog\/running-procces-in-background\/#article","isPartOf":{"@id":"https:\/\/www.btb4net.com\/borenblog\/running-procces-in-background\/"},"author":{"name":"Pavlovi\u0107 Branislav","@id":"https:\/\/www.btb4net.com\/borenblog\/#\/schema\/person\/1b2f711186b5e6d2f949b93ce659fa28"},"headline":"Running proccess in background","datePublished":"2009-05-25T20:43:16+00:00","dateModified":"2014-04-17T09:22:28+00:00","mainEntityOfPage":{"@id":"https:\/\/www.btb4net.com\/borenblog\/running-procces-in-background\/"},"wordCount":29,"articleSection":["VB.NET"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.btb4net.com\/borenblog\/running-procces-in-background\/","url":"https:\/\/www.btb4net.com\/borenblog\/running-procces-in-background\/","name":"Running proccess in background - Branislav Pavlovic","isPartOf":{"@id":"https:\/\/www.btb4net.com\/borenblog\/#website"},"datePublished":"2009-05-25T20:43:16+00:00","dateModified":"2014-04-17T09:22:28+00:00","author":{"@id":"https:\/\/www.btb4net.com\/borenblog\/#\/schema\/person\/1b2f711186b5e6d2f949b93ce659fa28"},"breadcrumb":{"@id":"https:\/\/www.btb4net.com\/borenblog\/running-procces-in-background\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.btb4net.com\/borenblog\/running-procces-in-background\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.btb4net.com\/borenblog\/running-procces-in-background\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.btb4net.com\/borenblog\/"},{"@type":"ListItem","position":2,"name":"Running proccess in background"}]},{"@type":"WebSite","@id":"https:\/\/www.btb4net.com\/borenblog\/#website","url":"https:\/\/www.btb4net.com\/borenblog\/","name":"Branislav Pavlovic","description":"My Portfolio","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.btb4net.com\/borenblog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.btb4net.com\/borenblog\/#\/schema\/person\/1b2f711186b5e6d2f949b93ce659fa28","name":"Pavlovi\u0107 Branislav","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.btb4net.com\/borenblog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/62c17a10b5883b6f49efea84199811ef?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/62c17a10b5883b6f49efea84199811ef?s=96&d=mm&r=g","caption":"Pavlovi\u0107 Branislav"},"url":"https:\/\/www.btb4net.com\/borenblog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.btb4net.com\/borenblog\/wp-json\/wp\/v2\/posts\/258","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.btb4net.com\/borenblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.btb4net.com\/borenblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.btb4net.com\/borenblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.btb4net.com\/borenblog\/wp-json\/wp\/v2\/comments?post=258"}],"version-history":[{"count":8,"href":"https:\/\/www.btb4net.com\/borenblog\/wp-json\/wp\/v2\/posts\/258\/revisions"}],"predecessor-version":[{"id":401,"href":"https:\/\/www.btb4net.com\/borenblog\/wp-json\/wp\/v2\/posts\/258\/revisions\/401"}],"wp:attachment":[{"href":"https:\/\/www.btb4net.com\/borenblog\/wp-json\/wp\/v2\/media?parent=258"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.btb4net.com\/borenblog\/wp-json\/wp\/v2\/categories?post=258"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.btb4net.com\/borenblog\/wp-json\/wp\/v2\/tags?post=258"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}