15,792,060 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Python questions
View Java questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by All Time Programming (Top 70 by date)
All Time Programming
1-Feb-14 3:15am
View
I tried forcing to compile using x86 platform only, but that didn't worked for me. Finally I tried installing the Driver from http://www.microsoft.com/en-us/download/confirmation.aspx?id=23734# and that made my app running back to normal.
All Time Programming
12-Mar-12 6:13am
View
Hello, To make sure at the client side, I added 1 more comment while the request to the server is sent in SendPost(). I see there the duration is longer. In the logs, see the 2nd one in bold, there the duration to actually sent the POST is delayed. What can be the reason for that.
REQEST: Kindly see the question, have added code for "SendPost()" and new logs.
Hoping to find the cause at the earliest.
All Time Programming
7-Feb-12 1:07am
View
Deleted
Reason for my vote of 5
Very simple and straight forward solution. I don't think this problem can have a better alternative.
All Time Programming
7-Feb-12 1:05am
View
Deleted
@Member 3896609, If we use TeeOutputStream then our application also neds to add Apache lib. I don't think that can be recommended for this simple task and just to avoid implementation of MultiOutputStream. Instead I would implement the class and minimize my application size (by not adding apache lib).
All Time Programming
16-Jan-12 0:54am
View
Deleted
Thanks reza kia.
Good to know that it helped some one.
All Time Programming
12-Jan-12 0:44am
View
Deleted
Reason for my vote of 5
Excellent thought. Though due to lack of initialization I always prefer variable backed Property; but using a Property without variable and yet initializing a default value - excellent. Something purly out of the box.
All Time Programming
12-Jan-12 0:39am
View
Deleted
Reason for my vote of 5
Seems to be best of all. I agree with BillWoodruff of describing this and other options in article. That would definetely help others understand what to adapt and why ?
All Time Programming
12-Jan-12 0:37am
View
Deleted
Always less code is not important or required. Many times or for better performance we need to implement more code though their may be another implementation method which uses less code. But that will 99.99% affect either performance or results.
All Time Programming
7-Sep-11 8:42am
View
Nope that doesn't show the window only - the app just exits. Actually, I am able to access only my: DataGrid, DataGridCell, DataGridCellsPanel, DataGridHeaderBorder & DataGridRow - I tested in xaml to see if I can access DataGridColumnHeader or not !
All Time Programming
7-Sep-11 7:56am
View
Hi Wayne, I already added namespace in Window declaration. But yet in Style, I can't access my:DataGridColumnHeader. It gives me "The type reference cannot find a public type named 'DataGridColumnHeader'. "
To know if I can access it or not, in the main Panel, I tried typing
<my: &="" can="" have="" access="" to="" only="" datagrid,="" datagridcell,="" datagridcellspanel,="" datagridheaderborder="" and="" datarow="" in="" respect="" datagrid="" classes.=""
i="" tried="" adding="" inside="" <my:datagrid.resources=""> but can't access it here also - shows same error msg.
If I use DataGridCell, then all row's cell are set with the style and col headers only when mouseOver, else normal headers only. I want to have seperate style for Headers and Rows. How do I achieve Style with Col Headers ?
All Time Programming
6-Sep-11 3:28am
View
Deleted
Reason for my vote of 5
Good article with clear explainations.
All Time Programming
29-Jul-11 7:36am
View
@John, the PNG has transparency colors. If it wouldn't be supportive then in Transparency tutorial project, it wouldn't show me the shapeful image. Even in an Image editor I see the image with transparent colors.
All Time Programming
13-Jul-11 8:31am
View
Thanks Ramalinga, but its a win forms app so no CSS or GDI+, etc.
All Time Programming
13-Jul-11 8:31am
View
Thanks Prerak, I had already loooked at that link. From that I just need the TekenRondeRechthoek() that does the painting rounded border. The issue is how, from where do I call that method. And for just 2 textboxes, this huge custom control, I don't think it worthful.
Is their any other solution, maybe simpler or a method via which I can call the above method.
Any help is highly appreciated.
All Time Programming
8-Jul-11 6:12am
View
Sanjay, the following links will help you achieve your goal :
Background Highlighting with the RichTextBox the System way:
http://www.codeproject.com/KB/cpp/tarrorichtextbox.aspx
Richer RichTextBox (Part 2):
http://www.codeproject.com/KB/edit/RicherRichTextBox.aspx
Look for Justification in below link
http://geekswithblogs.net/pvidler/archive/2003/10/15/182.aspx
Am sure the above links will provide you what you are looking for. I found the last one most helpful. Check out.
All Time Programming
7-Jul-11 10:39am
View
Are you saying is : This is the text
Rich Text Box
Justify Left & Right
Does it work ?
AND ON button click, you want is :
Rich Text Box
Justify Left & Right
Does it work ?
Something like this ? If not, send at : terry_513@yahoo.com
Confirm your requirements.
All Time Programming
6-Jul-11 8:30am
View
Kindly look at :
http://www.dotnetspider.com/resources/4644-Merge-columns-DataGridView-Excel-Spread.aspx
http://www.codeguru.com/forum/showthread.php?t=415930
http://social.msdn.microsoft.com/forums/en-US/winformsdatacontrols/thread/fea3dcff-5447-450a-8f7c-bb1c4f63371d/
For more, Google it and you will find lots of helpful solutions.
All Time Programming
6-Jul-11 3:26am
View
By default the RichTextBox's "RightToLeft" property is set to No which makes it left align.
On your button click event change "RightToLeft" property to "Yes" and your text will be right aligned.
Have updated the solution and also provided the code. Check out.
All Time Programming
6-Jul-11 3:15am
View
Deleted
By default the RichTextBox's "RightToLeft" property is set to No which makes it left align.
On your button click event change "RightToLeft" property to "Yes" and your text will be right aligned.
I tried and its' working.
private void button4_Click(object sender, EventArgs e)
{
// Check if it is Left aligned
if (richTextBox1.RightToLeft == RightToLeft.No)
richTextBox1.RightToLeft = RightToLeft.Yes; // If so, turn it to Right Aligned
else
richTextBox1.RightToLeft = RightToLeft.No; // If Right aligned, turn it to Left aligned
}
All Time Programming
5-Jul-11 4:27am
View
My 5. Return value is always more preferred and work best in all cases than out. Then you may return a single string or an string[], return type will work more better than out.
All Time Programming
5-Jul-11 2:57am
View
Deleted
Reason for my vote of 5
Good, Simpler and easy to implement and read.
All Time Programming
5-Jul-11 2:50am
View
Deleted
Reason for my vote of 5
I liked it. Found it helpful and worthy. Thanks for sharing.
All Time Programming
5-Jul-11 2:41am
View
Deleted
You have worked hard for this, showed good examples but I agree with RakeshMeena & Philippe Mori, this is good for begineers to understand the use of operators; but in practical one would never use such a way to find results. Keeping a look on complexity, performance and unnecessary calls of methods, one would never approach such methodology. Like in DoSequenceOfOr, if first method returns true then the whole operation will be true only, then why still need to excute the other 2 methods to look for their results! This simply takes more time then a normal operation doing the same functionality.
All Time Programming
5-Jul-11 2:12am
View
Deleted
Reason for my vote of 4
Good options
All Time Programming
17-Jun-11 12:04pm
View
Thanks BobJanova, that did the work for me. Their was no need to use Invoke to call ConnectClicked. CallToReConnect is called on normal UI thread only.
All Time Programming
17-Jun-11 6:31am
View
What is the safe way wo work with this. If the user clicks close btn at that time then also the app doesn't crash. @Lukeer, with the above version if user tries to close app "x" it crashes.
All Time Programming
17-Jun-11 5:37am
View
Thank lukeer, Sorry am not good at this. The above code gave error "The name 'SomehowInvoke' does not exist in the current context". I added a method SomehowInvoke but that also didn't work - knowing that, that is not correct. What do I nned to correct with above code to make it work ?
All Time Programming
17-Jun-11 3:40am
View
Thanks Punit, In your while loop I have a problem. I can call a method (Connect()). If that fails - canot connect the I got to wait for 30 secs and then only try again. Over here what happens is as this is Asyn, Connect() has started its work, nect line i.e. check if its connected or not. As yet it is not connected, so it will wait for X secs and start Connect() again. I don't want this part to happen that's why I added the waiting in RunCompleted and then start background thread again which calls Connect(). Do you have a way to solve out this part ?
All Time Programming
16-Jun-11 8:13am
View
Was in full confusion for whose answer to Accept ! Voted 5 for each answer. But as Member_6499766 had lowest score from you 3 and his answer was to point, so accepted his. Solutions of 3 of you are right and appropriate to great extend. Thanks to all of you. Thanks.
All Time Programming
15-Jun-11 4:12am
View
Thanks to all of you. My app is a UI clirnt and I already use BackgroundWorker thread for all activities. The current case is, if the connection is lost, I want to try connecting untill suceeds or an erro occured. Maybe I call background thread for reconnecting, in RunCompleted how to make it call recursively untill a variable (connected) is set to true.
Do you say that in RunCompleted, I check the variable and if its false, call another mthod that inturn calls/starts backgroundthread ? And if error is raised the background thread is cancelled any ways.
Is this true by what I understand you experts are trying to say !
All Time Programming
2-Jun-11 3:54am
View
Yes Bob that worked out. I just had to set a fld on cancelbtn as on closing the window normally (without clicking any thign) also the results received by ShowDialog was DialogReselt.Cancel. The flag helped me check if cancelbtn was pressed on the event is cauht normally. Thanks alot.
All Time Programming
1-Jun-11 10:33am
View
Wayne, Thanks but the bgworker is nover cancelled and it works normally completing its task. But throws an exception "Object reference ...." If I press ok on that error, the app quits.
All Time Programming
1-Jun-11 7:38am
View
BobJanova, I got te backgroundworker thread running and also showing the dialog. Ofcourse,when the task called by DoWork is completed, it goes to RunWorkerCompleted and I close the child form over there. But, I also want the privilege to cancel the DoWork task when the Cancel button is clicked on the childForm. I tried thru EventHandler handling in the parentForm. But in childForm, in cancel_btn_click event if I write event DialogCanceled(this, new EventArgs()); it gives me error during compile time. How do I handle this ?
All Time Programming
31-May-11 12:03pm
View
Actually not necessary that the user got to click "Cance" button. The dialog appears till the main form performs an activity. If the activity is finished, the dialog should be closed by main. If user clicks cancel then other code has to be performed by the main form. This is the exact scenario.
All Time Programming
31-May-11 2:52am
View
Deleted
Good and safe option for those who prefer such coding style. I don't use "with" in vb nor will use this option, as I prefer using the actual variable itself, I feel that makes code more neat and readable. But really good option for whomsoever uses it. Alternates provided are also possible, but I don't like that style neither.
All Time Programming
10-May-11 1:50am
View
Deleted
Best of all. Safe and accurate results for all to any user and any systems(32 or 64 bit).
All Time Programming
10-May-11 1:48am
View
Deleted
Reason for my vote of 5
Best of all. Provides accurate results regardless of 32 or 64 bit folders, uninstalled but folder exists etc. If it will be installed it will be lised else not. Will provide best and accurate response for every user.
All Time Programming
10-May-11 1:46am
View
Deleted
This is also a good option, but I would rather prefer Charles Opperman's Alternative. In that regardless of your system is of 32 or 64 bit, uninstalled but the folder exists, etc nothing matters; You just get the right and appropriate answer. If it is installed it will be listed, if uninstalled it wont be present even is the folders still exists. That will be much safe and accurate response.
Thanks for sharing. I learned something new from your option also.
All Time Programming
28-Feb-11 6:15am
View
OriginalGriff, my mistake regardng asking for DB connectivity. Sorry its for Server connectivity. It would be good if you can look at the code and guide me accordingly. - Thanks
All Time Programming
28-Feb-11 6:13am
View
Any help/guidance for the above query ?
All Time Programming
28-Feb-11 1:16am
View
Kindly refer the changes doen in the question and try to help accordingly. Please. I don't understand which aspect of threading to use and how to start with it. Once I get that part, will be ble to move ahead with it. Would be glad if you can help for it also. Thanks.
All Time Programming
25-Feb-11 12:49pm
View
Marcus & OriginalGriff, Kindly have a look at the updated question. Thwie was mistake in my question and try to help me regarding it. -Thanks
All Time Programming
23-Feb-11 6:11am
View
John, I made a 32bit and 64bit versions of my app. And als oa 32bit detector app. Am not able with the further steps. Can you please be precise about it and help me out. Thanks.
All Time Programming
23-Feb-11 6:07am
View
I don't want version, I want architecture. If I get Version as Vista, then that's avaialble for 32 bit also and 64 bit also. So architecture is imp than version and VersionNT provides only version. Thanks. Any way to find architecture.
All Time Programming
23-Feb-11 6:05am
View
Thanks Oliver, But if that key is found the value returned is "" as their is only Default property whose value is "". If the key isn't found then also the value remains "" only. So it doesn't help in either ways.
All Time Programming
22-Feb-11 9:59am
View
John, I can create a small app that helps meknow the system is of 32 or 64 bit and I create an installer for the same. From my main installer I will run the above installer. How will the main installer know the results that are found by the 32 bit installer ? I don't get how will be the flow. Created a 32 bit (detect 32/64 bit) installer and other 2 installers for main app for 32 bit and 64 bit. Now how to proceed, I don't understand you that flow. Unless I don't execute the 32bit application, how can I even note anywhere the system info. Can you please clear it .
Thanks
All Time Programming
22-Feb-11 8:42am
View
Thanks Olivier,
can you or anyone tell how to check the registry node in installation file ???
All Time Programming
22-Feb-11 8:11am
View
Thanks John, Actually the setup needs to install a driver in installation proess. And the exe file for the drive differs for 32 & 64 bit. In that case wanted to know if in installtion I can find the architecture then can execute respective exe file only (I guess using some Custom Actions that are meant for such things.). The whole application runs on 32 and 64 bit finely, just this driver installation is causing the problem. I have writen code in my app, that can tell me the OS, and architecture, but that will be executed after install & while executing. I want to install the driver while installation only.
I hope I have made myself very clear. In this case how to tackle.
Thanks
All Time Programming
22-Feb-11 7:37am
View
Ok, so windows version may not be a factor for me but architecture is surely is. While installation, based on 32/64 bit have to execute an exe file. I use Setup Project of Visual Studio. Can you tell something about this.
Thanks
All Time Programming
22-Feb-11 7:34am
View
Thanks Eduard,
Can you tell something more about the "running process" in the SEtup Project to identify the windows version. And an idea on how to work out.
All Time Programming
22-Feb-11 7:32am
View
I have used Setup Project of Visual Studio 2008.
All Time Programming
17-Feb-11 4:04am
View
Friends, have already added my code in the question. I hope that will help you to know my problem much better. Thanks.
All Time Programming
17-Feb-11 3:48am
View
I didn't get what you are trying to say !!
All Time Programming
17-Feb-11 3:47am
View
Thanks JF2015.
All Time Programming
15-Feb-11 8:57am
View
Asking the user to set the file as "Run as Admin", doesn't look professional. I have seen applications that use openvpn and doesn't need or any UAC prompt comes up. I was also looking for such kind of solution. Well, I found that problem in Win 7 and today only found that if I run as admin & set the Compatibility mode, the problem doesn't arise i.e. openvpn runs else it wasn't running only. So thought to add it for a better application.
All Time Programming
15-Feb-11 8:39am
View
Thanks Nishant & John. I will chekc both the links add my app details to Regitry and do the needful. Before that I have a question, In my application, I use openvpn.exe. If I set the Registry and UAC settings as you both said, will my application be able to run the openvpn.exe as an admin. I got to run openvpn.exe as Admin. My application itself doesn't need so but openvpn needs it in windows 7. So by doing the above will my application be able to run openvpn.exe (from cmd) as an Admin. Whose Compatibility mode should I change? It needs to be chanegd of openvpn.exe. Kindly help me know that will the above able to achieve my goal ? Thanks for your prompt response and look ahead for the same. Thanks.
All Time Programming
10-Feb-11 4:12am
View
tHANKS jf2015, I tried with Enviornment.CurrentDirectory + "\\openvpn...." . This should work with all cases I think so. Am I right or wrong ?
All Time Programming
10-Feb-11 1:04am
View
Thanks SA. My work is like on a btn click, a activity is done that takes some time. I show a waiting dailog (another component) to let the user know that some & what process is going beyond. Based on the process of the activity, i wanted to update the labels of WaitingDialog dialog. In this case, what Prerak Patel showed worked best for me. Thanks SA.
All Time Programming
9-Feb-11 5:37am
View
Thanks Manas. It helped me gain what it wanted to do. Thanks once again.
All Time Programming
9-Feb-11 5:01am
View
Perak Patel, Thanks a lot. Yes I implemented waitDlg.Message in backgroundWorker1_ProgressChanged and for calling backgroundWorker1.ReportProgress(0, message). Thanks a lot once again.
All Time Programming
9-Feb-11 4:16am
View
Thanks. Had a look at the link, but didn't get it .CODE has been added above from "Here is the code :". I will have 2 types of messages : "Retrieving data from ..." & "Falure" that are used in methods that are called via backgroundWorker thread. How do I add delegate, I don't know. Do you mean that whenever I want to change the message I should set the msg in some variable and somehow call progresschanged and add waitDlg.Message = newMessage; ??? Kindly guide me. - Thanks
All Time Programming
3-Feb-11 5:20am
View
I had a look at the BackgroundWorker. My requirement is I don't want any progress bar or so. Only a kind of Modal dialog with text like "Connecting" or "Retrieving..." while a method is executing. Once the method is executed, the dialog goes away. That's it. Modal dialog because, user know somethign is going on and he can't access any other form resources.
I added backgroundWorker on my form, but didn't get an idea of how to display a dialog with message and call the method and show the dialog till its done.
Can any body guide me for hte above.
Thanks
All Time Programming
2-Feb-11 9:50am
View
John, the server prints date and time prior to message, so I can' use startsWith(). But changed string.isullOrEmpty(d).
The out was :
LINE = Wed Feb 02 20:15:56 2011 Cannot load file :fopen:No such file or directory: error:2006D080:BIO routines:BIO_new_file:no such file: error:0B084002:x509 certificate routines:X509_load_cert_crl_file:system lib
LINE = Wed Feb 02 20:15:56 2011 Exiting
Execution Completed
This says that "Cannot load file" has come from output. But when I debug, the cursor goes once in ConnectServer() and then stays in while loop only.
All Time Programming
2-Feb-11 8:09am
View
then how to achieve it ?
My process wont be completed as I am connecting to server so it has to stay untill I disconnect it from app.
Can you help me our guide me for the above .
Thanks
All Time Programming
2-Feb-11 3:45am
View
Thanks a lot. I guess last query reg the topic :
Am not ablt to stop the thread. Thread still seems to be alive/active. My code:
<pre>
try
{
conThread = new Thread(new ThreadStart(StartConnect));
conThread.Start();
//conThread.Abort(); // SEEMS NOT TO EXECUTE
}
catch (ThreadAbortException te)
{
Console.WriteLine("Abort Exception CAUGHT");
}
catch (Exception ex)
{
if (ex.Message.Equals("NotConnectedException"))
MessageBox.Show("Unable to connect to the Server", "Time Out", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
else
MessageBox.Show("Error connecting to the Server : " + ex.Message, "Failed to Connect", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
finally
{
conThread.Abort(); // SEEMS NOT TO EXECUTE
Console.WriteLine("Thread ISAlive = " + conThread.IsAlive); // Shows TRUE
}
MessageBox.Show("***************** Connected To VPN Server - " + connectedTosERVER); // DISPLAYS
Console.WriteLine("Execution Completed "); // DISPLAYS
</pre>
aFTER starting the thread and once the StartConnect()is executed, i should stop/suspend the thread in any way. Calling Abort() after start() or in finally block seeems to have no response. And IsAlive still shows true only. I want ot stop the thread and I belive isalive should show false as the thread is no more active. The MessageBox and "Execution Completed" is also shown. But what about stopping - i mean closing the thread from scratch as the same thread wont be used anywhere in the app except again in the same method.
I looked alot on various sites and tutorials, but couldn't find the solution. Thread.Suspend does, but it is deprecated so don't want to use that one.
What can be the best solution or am I misunderstanding anything here ?
Thanks a lot.
All Time Programming
1-Feb-11 9:04am
View
How do you get the timepassed ? I lloked at Thread, Timer(s), DateTime but couldn't find anything that can tell me how much time has passed. Well in DateTime can get the milisecond but of the current time and not timer wise.
For implementation I came to :
<pre>
Thread conThread = new Thread(new ThreadStart(StartConnect));
conThread.Start();
private void StartConnect()
{
int timeout = 30000, timepassed = 0;
OpenConnect oc = new OpenConnect(cmd, timeout);
int retVal = oc.ConnectToServer();
while (!oc.Connected)
{
if (timepassed > timeout)
throw new Exception("NotConnectedException");
Thread.Sleep(100);
}
if (retVal == 1)
Console.WriteLine("YES CONNECTED AND RETURNED");
}
</pre>
This would be more safe , if I am not wrong.
Please guide me.
All Time Programming
1-Feb-11 7:44am
View
I am not getting your point. Can you show a code or sample on other url. According to you, it should be something like this :
<pre>
process.OutputDataReceived += new DataReceivedEventHandler(Process_OutputDataReceived);
while(connected) {
}
</pre>
I feel am wrong somewhere but don't get where. With this the process will also be live and the stringBuffer will also be filled continously, right !
I will Accept your ans and also vote 5, but once my point is suceeded. Have faith.
Thanks
All Time Programming
1-Feb-11 7:12am
View
Tried to implement in a new class :
<pre>
public class OpenConnect
{
private Process process;
private ProcessStartInfo processInfo;
private bool connected;
private string command;
private int timeOut, ExitCode = -1;
private StringBuilder sb;
public OpenConnect(string Command, int timeOut)
{
this.command = Command;
this.timeOut = timeOut;
init();
}
private void init()
{
processInfo = new ProcessStartInfo("cmd.exe", "/C " + command);
sb = new StringBuilder();
processInfo.UseShellExecute = false;
processInfo.RedirectStandardOutput = true;
processInfo.CreateNoWindow = false;
}
public int ConnectToServer()
{
try
{
process = Process.Start(processInfo);
process.BeginOutputReadLine();
process.OutputDataReceived += new DataReceivedEventHandler(Process_OutputDataReceived);
if (connected)
return 1;
/*
// Get the results
string result = process.StandardOutput.ReadToEnd();
Console.WriteLine("Process Result = " + result);
//Process.WaitForExit(30000);
ExitCode = process.ExitCode;
Console.WriteLine("%%%%%%%%%%% EXIT CODE = " + ExitCode);
process.Close();*/
}
catch (Exception e)
{
Console.WriteLine("Error Processing ConnectToServer : " + e.Message);
}
finally
{
//Process = null;
//ProcessInfo = null;
}
return ExitCode;
}
private void Process_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
string d = e.Data;
Console.WriteLine("LINE = " + d);
if (d != null && d.IndexOf("Initialization Sequence Completed") > 0)
{
connected = true;
Console.WriteLine("********* Connected = " + connected);
}
}
public void DisconnectServer()
{
processInfo = null;
if (process != null)
{
process.Close();
}
}
}
}
</pre>
How to check the state of connected over here ?
If I return from this class, I believe the process will be working on background and I will be able to call Disconnect and it will perform as expected. Please correct me If i got to improve something here.
And for the state of connected ?
Thanks
All Time Programming
1-Feb-11 6:37am
View
Yes JF2015. That helped to display data directly to console. Now I got to return the funtion when I read "Initialization Completed". In the delegate(), I might write :
<pre>
string d = e.Data;
Console.WriteLine("LINE = " + d);
if (d != null && d.IndexOf("Initialization Sequence Completed") > 0)
{
connected = true;
Console.WriteLine("********* Connected = " + connected);
}
AND IN ExecuteCommand CODE :
process = Process.Start(ProcessInfo);
process.BeginOutputReadLine();
process.OutputDataReceived += new DataReceivedEventHandler(Process_OutputDataReceived);
if (connected)
return 1;
</pre>
iN MY OUTPUT I GET :
LINE = Tue Feb 01 17:01:27 2011 Initialization Sequence Completed
********* Connected = True
But the if(connected) is not executed to return. I want to keep the process live and return. How to return from ExecuteCommand.
I guess i got to create a seperate class for this where Process is a member and can keep it ailve and kill when am done.
What do you say ?
How to return form the delegate() ?
Thanks
All Time Programming
1-Feb-11 5:37am
View
I tried your latest code, but that also doesn't help. My command is :
openvpn --config client.ovpn --ca certificate.cer --auth-user-pass user.txt
Trying to connect to openvpn.
And when I find "Initialization Sequence Completed" I want to return to inform the user about connection successful. With your code also I don't see any text without pressing Ctrl+C. To stop openvpn, I got to press "F4" on command prompt. Till then the command prompt is active and in running mode. But I want to return my function once I have connected or receive any such error message from the openvpn.
From the link you provided, do you think "BeginOutputReadLine" could be of use as that's the only thing I have not implemented or tried in my code.
Thanks
Show More