SgDotNet
Singapore Professional .NET User Group -For Cool Developers

Code snippet - 0009

This post has 15 Replies | 3 Followers

Top 50 Contributor
Posts 82
ericwsw Posted: 04-23-2005 10:59 AM

Run a process (Can be wait for that process to exit before continuing)

 Private Sub CallProcess(ByVal path As String, ByVal Arguments As String, ByVal WindowStyle As ProcessWindowStyle, ByVal WaitForExit As Boolean)

        If System.IO.File.Exists(path) Then

            Dim p As New System.Diagnostics.Process

            p.StartInfo.FileName = path
            p.StartInfo.Arguments = Arguments
            p.StartInfo.WindowStyle = WindowStyle
            p.StartInfo.ErrorDialog = True

            p.Start()

            'Wait until the process passes back an exit code
            If WaitForExit Then
                p.WaitForExit()
                p.Close()
            End If

        End If

    End Sub

Implementation

CallProcess("C:\Acrobat 6.0\Reader\AcroRd32.exe", String.Empty, processWindowStyle.Maximized, False)

 

Top 10 Contributor
Posts 2,891

Ericsw,

Its very nice of you to share these code snippets, but it would be even better that you put the subject to the nature of the snippet instead of just a running number. I'm sure it will be much easier for you to refer next time, and others can see the nature of the snippets immediately.

Best Regards, Kit Kai, MVP (SharePoint Portal Server)

Top 10 Contributor
Posts 1,626

I have to agree with kitkai that the subject of the post is too weird. At first, I thought it was a series of code-dump from a program for trouble-shooting purpose and I didn't even bother to click on it. Only today, I read all 9 of them and found out that they are quite useful.

How about posting the code snippets as short articles? We do have an article section here. More elaboration may be needed though instead of plain code-dumps. Geeked [8-|]

Software development made easy with Paladin RAD Framework. Save some trees, use Stickies.NET
Top 50 Contributor
Posts 82

Thank for feedback Smile [:)]. In future I will put the serial into the message body.  The series just for me to keep track how many code snippet has been posted. I'm will very appreciate if  we can have a code library section to keep all the code snippet.

If all of the member can contribute one or two code snippet per week, it will become a huge library and bring greater benefit to all of us.

 

Top 10 Contributor
Posts 1,626
If your posts are put into the article section, you may also want to let people download the sample code.Geeked [8-|]
Software development made easy with Paladin RAD Framework. Save some trees, use Stickies.NET
Top 50 Contributor
Posts 82

All the code snippet can be simply cut and paste. Hereby you can simply keep it in anywhere you want. Personally don't recommend to keep in project format because it hard to find.

All the code may not perfect, I very appreciate if someone can improve it.

Recommended Tools for keep your code. 

http://www.garybeene.com/free/fr-librarians.htm

For those are using VS 2005, is that any great tool for keep the code snippet?

 

Top 10 Contributor
Posts 2,284
 ericwsw wrote:
All the code snippet can be simply cut and paste. Hereby you can simply keep it in anywhere you want. Personally don't recommend to keep in project format because it hard to find.

/forums/14618/ShowPost.aspx

The melody of logic will always play out the truth. ~ Narumi Ayumu, Spiral

Top 50 Contributor
Posts 82

Hmm ... u may have some miss understanding. I post the code snippet because is simple and easy to digest by more of reader especially for the beginner. Actually, they are freely to build their own component using the code snippet. Or they can copy and paste to keep somewhere for future reference.

Agree with you for the componet re-used concept and I always promote that. Actually more of the code snippet is part of my re-useable component. By the way not all the time the code need to repeat and repeat again, is practical to build as a class, hereby code snippet will become very useful, just copy and paste the code and then configure it. In this scenerior, I classify it as code template.

 

 

 

Top 25 Contributor
Posts 485
Hi, you may want to take a look at this

http://www.codexchange.net/

A plugin for VS to share code snippets
Yes, another version, another round of headaches. But that's progress.
Top 50 Contributor
Posts 82

Thank. But it seem not working with my Norton Firewall, hence I have to give up. Are you using it?

Personally, I'm using CodeSmith to generate my code template or class and keep my code snippet

http://www.ericjsmith.net/codesmith/

 

Top 25 Contributor
Posts 485
It works for me, but so far I have not try upload any snippets up to the database yet. Not very sure if it might conflict with norton firewall though.

I used to just paste them onto VS toolbox, but not a good way of storing as its not very portable.

I do agree with icelava that a better way is to generate a class library for frequently used codes. Usually for me, code snippets are codes tat 'will/may be useful but not of immediate use now'. For those codes that definitely will be use from time to time(like checking whether a string can be converted to int in C#), will be better to generate a class library.

Yes, another version, another round of headaches. But that's progress.
Top 50 Contributor
Posts 82

Ohh ..maybe need to try it again. Consider to shift the coming snippets to the database if I can connected to the server.

I'm building a very rebust component can handle all common routine that will be make my life easy for quite sometime, maybe the code library on the codeXchange will be help me to speedup.

Anyway thank for the information.Big Smile [:D]

Top 50 Contributor
Posts 82
I manage to connect to the server and have post my new snippets into the server. Anyone need the snippets, you can get it from codeXchange. Smile [:)]
Top 25 Contributor
Posts 485
Wow, thats great. So did the problem lies with Norton firewall ? Maybe can share how you managed to solve the initial problem of not able to connect to the server cause I think others could/might face the same problem also
Yes, another version, another round of headaches. But that's progress.
Top 50 Contributor
Posts 82

Not really ... Because I'm access throught the Proxy Server at my office, hereby is no Norton Firewall involve.

At home, I using Norton Firewall stop certain applications from gaining access to the net. so I can't disable it. Maybe I need to find out how to configure it manually.

Page 1 of 2 (16 items) 1 2 Next > | RSS
Copyright SgDotNet 2004-2008
Powered by Community Server (Commercial Edition), by Telligent Systems