|
He's explained his problem clearly, if you can't understand it, why are you answering ? Nothing you've said is terribly helpful.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Escocia wrote: My real problem is that I need that this program runs constantly and for this reason I have created a while(true) loop.
This is dumb. It forces your code to work to do nothing, and that's why your CPU is 50% ( you're on a dual core and only one core is being needlessly worked by your code ).
Escocia wrote: The solution "Windows Service" is not valid because these are started before logon and these have not the
Permissions of the Domain.
Actually, that's not necessarily true, but, you don't need a service, your form will always run anyhow. If you need to check something and you can't watch for it, write a timer to check as often as is appropriate ( once a second, twice a second, once every ten seconds, it's up to you ).
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hi thanks for your Answer,
I've got a FileSystemSwatcher for changes...My problem is that the form finish...Sorry, I don't think that always run..
This is recomedation of Microsoft for Invisible Forms..
To make the main form of a Windows-based application invisible when the application starts, you must move the application's startup logic into a separate class. You cannot simply set its Visible property to false.
After you have separated the lifetime of the application from the lifetime of the form, you can make forms visible (and invisible), because the application will end when you "close" the class that was used for application startup.
Note
Because a module is invisible when its code is running, the procedure that follows includes a step for adding a message box to the startup module to simply demonstrate that the application is running.
To set a form to be invisible at its inception
Do one of the following:
In Visual Basic, add a module to your Windows-based application by right-clicking the project and choosing Add Module.
In Visual C#, create a new class.
For more information about creating a Windows-based application, see How to: Create a Windows Application Project.
Within the module or class, develop a Main subroutine that can act as the startup object for the project.
The following code example shows how you might approach this.
C# Copy Code
// All methods must be contained in a class.
// This class is added to the namespace containing the Form1 class.
class MainApplication
{
public static void Main()
{
// Instantiate a new instance of Form1.
Form1 f1 = new Form1();
// Display a messagebox. This shows the application
// is running, yet there is nothing shown to the user.
// This is the point at which you customize your form.
System.Windows.Forms.MessageBox.Show("The application "
+ "is running now, but no forms have been shown.");
// Customize the form.
f1.Text = "Running Form";
// Show the instance of the form modally.
f1.ShowDialog();
}
}
Note
The message box in the previous code example is specified with a fully qualified namespace because the created module, unlike a standard Windows Form, does not import any namespaces by default. For more information about importing namespaces, see References and the Imports Statement (Visual Basic), the using Directive (C# Reference) (Visual C#), or the using Directive (C++) (Visual C++). Application.Run() will start the message pump, which is vital to the behavior of certain applications and can affect form behavior during certain times in the application lifecycle, such as on shutdown. For more information, see Application.Run Method.
My code in the new class is:
class AnotherClass
{
static void Main()
{
Form1 miF = new Form1();
FileSystemWatcher Fs = new FileSystemWatcher();
Fs.Created += new FileSystemEventHandler(Fs_Created);
Fs.Path = "c:\\my";
Fs.EnableRaisingEvents = true;
miF.ShowInTaskbar = true;
while (true)
{ }
}
static void Fs_Created(object sender, FileSystemEventArgs e)
{
FileStream Fs = File.Open("c:\\my\\probe.txt", FileMode.CreateNew);
StreamWriter Sw = new StreamWriter(Fs);
Sw.WriteLine(e.FullPath);
Sw.Close();
Fs.Close();
}
}
Many Thanks
|
|
|
|
|
Escocia wrote: My problem is that the form finish...Sorry, I don't think that always run..
Well, that's not how forms work. They close when you close them.
Escocia wrote: Form1 miF = new Form1();
FileSystemWatcher Fs = new FileSystemWatcher();
Fs.Created += new FileSystemEventHandler(Fs_Created);
Fs.Path = "c:\\my";
Fs.EnableRaisingEvents = true;
miF.ShowInTaskbar = true;
You never show your form, hence there's no message loop, which is why it closes
Escocia wrote: while (true)
{ }
And this is the mess that's killing you.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Christian Graus wrote: Escocia wrote:
Form1 miF = new Form1();
FileSystemWatcher Fs = new FileSystemWatcher();
Fs.Created += new FileSystemEventHandler(Fs_Created);
Fs.Path = "c:\\my";
Fs.EnableRaisingEvents = true;
miF.ShowInTaskbar = true;
You never show your form, hence there's no message loop, which is why it closes
Hi, Thanks for your answer again!
I have prove to add the next line (1) and delete the while(true) loop and form is closed...
miF.Show();
Another solution??
Many Many Thanks.
|
|
|
|
|
Escocia wrote: miF.Show();
I guess you don't know much about winforms ? Have you thought of buying a book ?
miF.Show shows a modeless form, which means your code continues to run. miF.ShowDialog() shows the form modally, so the application runs until it is closed.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Christian Graus wrote:
I guess you don't know much about winforms ? Have you thought of buying a book ?
. Sorry...It's true, I'm promises that I know the Differences about Modal or not Modal... . Many time writing in the console mode... ;D
But, the most important it's works..Now I can add the real functionality of the program.
Many Thanks Christian!
Ps: When You talking about...
Escocia wrote:
The solution "Windows Service" is not valid because these are started before logon and these have not the
Permissions of the Domain.
Actually, that's not necessarily true, but, you don't need a service [...]
Have you got any link where speak about this this theme...I am very interesting, because I thought that windows Service can't access at privileges of the Domain..
Thanks!
Sorry For My English...I'm Spaniard
|
|
|
|
|
|
There's a WPF forum.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I wrote a C# program to create enhanced metafile and store to clipboard for paste on office application, I don't know while I change the clipboard view with picture and EMF, the image in clipboard becomes distortion with picture view
And I wrote a VB program also to create enhanced metafile and store to clipboard, it is no problem
Any one can give advice to me ??
|
|
|
|
|
C# and VB are identical. Therefore, there is a difference in your code, or in the files you're choosing to copy in each.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I mean I wrote VB program is VB6, it is not a VB.net
In VB, I implement CreateEnhMetaFile to create metafile
and C#, I implement MetaFile Class to create metafile
Is it different ???
|
|
|
|
|
In that case, it is different, yes, you may need to look into the metafile class to see where you may be going wrong.
I assume VB.NET when people say VB, as VB6 has been obsolete for a long time.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
|
|
Hi all,
Can somebody help me on how to create multiple connection to different server using ip/port at the same time and receive data.
I have a program in C# but it's only working for 1 connection. Please help me or redirect me for a tutorial on multiple socket programming in C#.
I'm new to this thing.
|
|
|
|
|
Multithreading will do the trick. Just open a each TcpListener or Socket(udp) connection in a seperate thread.
|
|
|
|
|
You've shown that you have the code to connect from one machine to another. Just duplicate it. Nothing says that you can have only one socket open at a time so it's fine to do something like this:
open Socket A
open Socket B
. . .
read something from A
. . .
write the data to B
. . .
close A
close B
you don't even need to close the sockets for each operation. You can leave them open for the lifetime of the process if you need to instead of opening them and closing them each time that you need them.
Unfortunately I don't have any links to tutorials on multiple socket programming; i doubt that any really exist. There's no real difference between using one socket and using multiple sockets except that in the former you see things like Socket and in the latter you'll see things like List ( Socket ) .
|
|
|
|
|
|
Using a COM object in PHP has nothing to do with C#, not even remotely. I dunno if PHP does COM ( I doubt it ), but the web dev forum is the one to try.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Thanks message reposted to web development
|
|
|
|
|
I am building a udp voice chat(p2p) application in csharp. Before starting chat one of the user must send a dialog box(yes/no) to other user to know whether the other user is intrested to chat or is busy in chatting with some one.
I am unable to do so .Plz help me out to pass a dialog box to other pc and get response back and act accordingly.
code will be more preferable than links
Thanx in advance.
|
|
|
|
|
You're going to need a network communication between the PCs in the first place, with your code running on both PCs, in order to send voice between them. There's no way that I can write code on my computer, to send a dialog box to your computer, and return a result. Imagine if that were possible, how insecure the web would be ? You need to write code to pass the request, receive the request, show the message box, and send back the result. Code you wrote needs to be running on both computers.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Dear Experts,
I have two questions here, first, I wanna know how to make an autonumber on C sharp (textbox). I have selected max number from a field in the table but I do not know how to make the textbox becomes an autonumber (always +1 with the max number) when I load the form.
The second question, I have many forms in my small (homework) project. I open form2 from form1(form1 still actives), I add some text in form2 and I want to make form1 (ex: combox) refresh (vba calls requery) when I close form 2.
Thanks for reading the entire of this passage.
Visoth
Chuon Visoth
Angkor Wat - Cambodia
asp.net - c sharp beginner
|
|
|
|
|
misCafe wrote: I have two questions here, first, I wanna know how to make an autonumber on C sharp (textbox). I have selected max number from a field in the table but I do not know how to make the textbox becomes an autonumber (always +1 with the max number) when I load the form.
There is absolutely no way to do this automatically - you will have to write your own control. The only logical way I can see to do this is to have a column to show numbers, not add text to the control.
misCafe wrote: The second question, I have many forms in my small (homework) project. I open form2 from form1(form1 still actives), I add some text in form2 and I want to make form1 (ex: combox) refresh (vba calls requery) when I close form 2.
When your call to ShowDialog ends, you still have the dialog object and you can access it's properties. So, just expose the values you need, and grab and use them.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|