|
There are heaps of commercial apps that do a good job of this. None are perfect, but once they are done, you can usually clean your code and get it running pretty quickly.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
|
We produce Instant VB, which will convert a C# app all at once (or an ASP.NET 2 web site, or folders, snippets, etc.).
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter, VB to C++ converter
Instant Python: C# to Python converter, VB to Python converter
|
|
|
|
|
hello again
well can any of u plz tell me how can we dynamically find and let the user connect with any sql server running on a pc, I saw n article here on this topic along time agobut I cant find it. I'm working in windows application C#2.0
thanks in advance
|
|
|
|
|
|
|
Have you found that to be reliable? I've tried a couple of different methods and sometimes they're returned and sometimes they're not. I have a mix of 2000 and 2005 servers.
|
|
|
|
|
I havn't had a problem but it's only been tested on a network where there were 3 2005 and 2 2000 servers and seemed to return them all (well most of the time but the one which didn't show up was mine because my laptop wasn't in work's domain at the time. Since then it seems to be working fine).
I have no idea what I just said. But my intentions were sincere.
Poore Design
|
|
|
|
|
hi every one,
I have two questions for u ppl here
well first one is that when u make a window application u get a form that actually comesup first when u run the application, if laterat some stage u wanna chg that then how do u do it??
2. I made a form and dropped a bindingNavigator objecton it, by default its color is like grey and has a shade on it... later I chaged that color and it was all plain uknwo. So now I wanna get that old color back or get that shade effect on again... so how can I do that??
thanks in advance
Rocky
|
|
|
|
|
Hi,
1)
there are basically two ways to have a switch of main form:
- inside static main() you have something like Application.Run(new Form1());
which creates your Form1, shows it, and runs a message loop on it, until you somehow
close that Form1. So if you need a Form2 after closing Form1, you could add
Application.Run(new Form2());
- an alternative is to keep static main as is, change Form1 to be invisible,
and let it create and show one or more forms at will, as in:
Form2 f2=new Form2();
f2.ShowDialog(); // = show and wait until closed
Form3 f3=new Form3();
f3.ShowDialog();
return;
of course, you can add any logic you need; or you could use Show() to see
several forms at once.
2)
Dont know, seems like a bug: initially blueish gradient, when changed, then
set back to BackColor=Control, it remain Control-gray (and the code is back to its
original !?).
Luc Pattyn
|
|
|
|
|
hmm that one looks helpful but u know I tried to change the color of the BindingNavigator back to control but its not giving the gradient effect on it anymore and it doesnt look good that way... well may be its bug but I hope its not and now I'm trying to do something abt that... hope something good comes up
thanks for ur help
Rocky
|
|
|
|
|
I have an application that will be running in the background and I want it to run every 5 minutes to check a file execute it and then wait another 5 minutes to do this. I tried doing this, but I get the following error.
Unhandled Exception: System.Threading.THreadStateException: Thread is running or terminated; it ca not restart.<br />
<br />
Thread t1 = new Thread( new ThreadStart(myMethod));<br />
bool start = true;<br />
int stop = 0;<br />
while(start)<br />
{ <br />
t1.Start(); <br />
Thread.sleep(5000); <br />
if(stop==1000)<br />
{<br />
start = false;<br />
} <br />
stop++;<br />
} <br />
<br />
|
|
|
|
|
You don't want the application controlling the thread sleeping, you want the thread itself sleeping and determining when to exit.
void MakeThread()
{
Thread t1 = new Thread( new ThreadStart(MyMethod));
t1.IsBackground=true;
t1.Start();
}
void MyMethod()
{
while (++stop != 1000)
{
Thread.Sleep(5000);
}
}
Note setting the IsBackground to true, so if your application exits, the thread will terminate too. Otherwise you can have threads running even when your application has quit.
However, this isn't really what threads are intended for. Sounds more like what you want is a timer that fires every 5 seconds.
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
You are restarting the thread every five seconds, not every five minutes. If the thread ever takes more than five seconds to complete, you will be trying to restart a thread that is still running.
---
Year happy = new Year(2007);
|
|
|
|
|
I concur with the previous remarks, but want to add you constructed a loop that
really deserved a for statement:
for (int i=0; i<1000; i++) {
// do here what has to be done periodically
// ...
// now wait
Thread.Sleep(5000);
}
This approach repeats an operation with (an attempt to) a fixed time lapse in between;
if you want (an attempt to) predictable starting times, you definitely need to use a timer.
Luc Pattyn
|
|
|
|
|
I thought using thread will make the methods to run every 5 minutes.
So basicly i want the application to run in the background, I don't want to open the WindowsConsole and to exit the program I want to go to the task manager to stop it. So how can I make this that every 5 minutes it executes MyMethod():
|
|
|
|
|
You can make an app that does not show its main form, but shows a NotifyIcon.
Its main task would be to either hold a timer or a wait loop (as I have shown),
so whatever needs to be done gets done periodically.
You could add a ContextMenu with an "Exit" menu item that stops it (no need to
kill it with Task Manager!), and possibly some other menu items that allow you
to see some status, or set some parameters.
I guess there must be several examples available on CodeProject.
Luc Pattyn
|
|
|
|
|
thanks for the suggestion, I think is a good idea to have a ContextMenu and and a textarea to check the status.
|
|
|
|
|
Hey, everyone. I know it's possible, but i don't know how to access the filetypes part of Windows Explorer. I need to access the ext., the path, the name, and the image. And is it possible to open up the filetypes dialog without opening up Windows Explorer (from my program)? Thanks.
|
|
|
|
|
look at the Path class, it has static methods for almost anything you may need.
Luc Pattyn
|
|
|
|
|
I've done something similar in VBA once. Take a look into BuiltInDocumentProperties, maybe you'll finf what you need
<br />
Public Function GetWordTitle(strFileName As String) As String<br />
Dim wordApp As New Word.Application<br />
<br />
wordApp.Documents.Open strFileName, , True<br />
wordApp.Visible = False<br />
GetWordTitle = wordApp.ActiveDocument.BuiltInDocumentProperties("Title")<br />
<br />
<br />
wordApp.ActiveDocument.Close False<br />
Set wordApp = Nothing<br />
End Function<br />
|
|
|
|
|
Hi ALL
How can I read text file and make some process on it after it uploaded on the server.
Ala Qunaibi
Ala Qunaibi
|
|
|
|
|
That depends, is it your server ? Do you want to read it on the server, or on the client ? Once it's gone to the server, the client can only read it if you write methods on the server to send it back down again.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thanks Christian Graus
I want to read uploaded text file on my server.
How can i do that?
Ala Qunaibi
|
|
|
|
|
OK, then exactly as I said, it needs to exist in a way that can be browsed to, or it needs otherwise to be exposed by the web site.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|