|
You can user PerformanceCounter component by setting CategoryName property to Network Interface and after selecting appropriate counter.
|
|
|
|
|
Hi
using api hooking you can monitor the network usage such:
wsock32.dll has two funcaiton in the socket level
1 send
2 receive
from that you can monitor and it works fine.and it calculates the entire upload download.
|
|
|
|
|
Hi
I`m trying to run timer on tick method after clicking the button and i dont really understand how it can be done.
can anyone help please ??
for example :
private void button1_Click(object sender, EventArgs e)<br />
{<br />
myTimer.Enabled = true; <br />
<br />
}<br />
<br />
private void myTimer_Tick(object sender, EventArgs e)<br />
{<br />
}<br />
|
|
|
|
|
I suppose you are trying to do something like this:
private void button1_Click(object sender, EventArgs e)
{
myTimer.Tick += new EventHandler(myTimer_Tick);
myTimer.Interval = 2000;
myTimer.Enabled = true;
}
void myTimer_Tick(object sender, EventArgs e)
{
MessageBox.Show("tick");
}
|
|
|
|
|
Yes indeed
Thank you very much
|
|
|
|
|
See my reply to the above answer if you find that it does not work as you want it too
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
I want to open Firefox ever hour!
void myTimer_Tick(object sender, EventArgs e)<br />
{<br />
System.diragnostic.process.start("firefox);<br />
}<br />
static void Listen()<br />
{<br />
<br />
<br />
while (true)<br />
{<br />
try<br />
{<br />
data = new byte[1024];<br />
received = networkStream.Read(data, 0, data.Length);<br />
if (received == 0)<br />
break;<br />
<br />
string get = Encoding.ASCII.GetString(data, 0, received);<br />
var send = get.ToByteArray();<br />
//Console.WriteLine("Received from TCP Client: " + get);<br />
networkStream.Write(send, 0, send.Length);<br />
<br />
<br />
if (get == "rstartFirefox")<br />
timer1.Tick += new EventHandler(myTimer_Tick);<br />
timer1.Interval = 3600000; // once every two seconds<br />
timer1.Enabled = true;
here it doesn´t work! the code works great by a Button_Click!
What can i do that it works here?
|
|
|
|
|
start by moving the following two lines to your constructor, and use it no where else
timer1.Tick += new EventHandler(myTimer_Tick);
timer1.Interval = 3600000
then after all the code you have posted add the following line to check what going on..
MessageBox.Show("get = " + get);
let me know what pops up and how many times.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Nothing!
Now i have it so!
I get the massage box!
Open also takes the correct value!
But he don´t open the Methode myTimer_Tick!
What can i do?
<br />
public Form1()<br />
{<br />
InitializeComponent(); <br />
}<br />
void myTimer_Tick(object sender, EventArgs e)<br />
{<br />
mciSendString("set CDAudio door open", null, 127, (IntPtr)0); <br />
}
if (get.Contains("rRegelmaessig_oeffnen"))<br />
{ <br />
Messagebox.show("Hello");<br />
string[] get_Split2 = get.Split('~');<br />
int open = Convert.ToInt32(get_Split2[1]);<br />
timer1.Tick += new EventHandler(myTimer_Tick);<br />
timer1.Interval = open * 1000; <br />
timer1.Enabled = true; <br />
}
|
|
|
|
|
what is the value of open?
How do you know that the Tick event is not being called?
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
you should not add the event handler in the button click event as you will get a new handler added each time you press the button. So in your example the message box will be shown the same number of times that the button has been clicked.
Just need to take out the adding of the event handler and put that line in the design code, or constructor, or anywhere it will only be called once.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Dear,
Every new form, I've to import using system.data.oledb. Is there anyways to make it default every new form?
Thanks,
Chuon Visoth
Angkor Wat - Cambodia
asp.net - c sharp beginner
|
|
|
|
|
Hi,
you cannot "import" the using statement automatically. But if you access everthing full qualified (e.g. System.Data.OleDb.DbConnection...) you don't need the using statement.
Don't know if I get your question right. The using-statement is just something like "syntactic sugar". It is just there to access classes within a namespace without using the fully qualified method. It is nothing like an "import".
Regards
Sebastian
|
|
|
|
|
got it!
thanks,
Chuon Visoth
Angkor Wat - Cambodia
asp.net - c sharp beginner
|
|
|
|
|
Yup
You can create "project" and "item" templates for re-use. Create a new project, add your references and choose "File", "Export Template". Export the project-template, and it will appear under "File/New" once you put it in the "\Templates" folder of Visual Studio (see "My Documents")
If you only want a form, and not a complete project, then add the using and start the export-wizard again. Select your form, export as a template and save the generated template under "My Documents\Visual Studio 2008\Templates\ItemTemplates\Visual C#"
I are Troll
|
|
|
|
|
Yes, but you have to either provide your own template or modify the MS ones.
Your own is easy: create an example of the form you want, and save it as a template in "My Documents\Visual Studio 2008\Templates\ItemTemplates\Visual C#"
Modifying the MS ones is also easy, but back them up first! Go to "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplatesCache\CSharp\Windows Forms\1033\Form.zip" and edit the the form.cs file. Add your using statements and save. Add...new...Windows Form will now include your stuff.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
The other answers are correct, but... your Form should not be accessing the database directly; write (at least) a Data Access Layer and then access that from your form.
|
|
|
|
|
Hi all,
Some one please can help me by converting the following code.
This works fine for the frames. and how to do for the other tags like button and links
The following code for frames works fine:
HTMLDocument document;
IHTMLElementCollection elcol = document.getElementsByTagName("iframe");
foreach (IHTMLElement iel in elcol)
{
HTMLFrameElement frm = (HTMLFrameElement)iel;
DispHTMLDocument doc1 = (DispHTMLDocument)((SHDocVw.IWebBrowser2)frm).Document;
DE = (HTMLDocumentEvents2_Event)doc1;
DE.onclick += new HTMLDocumentEvents2_onclickEventHandler(DE_onclick);
}
But i dont know how to do for the input buttons. Can you help me how to proceed with the following code.
IHTMLElementCollection buttons = document.getElementsByTagName("INPUT");
foreach (IHTMLInputElement iel in buttons)
{
HTMLInputElement button = (HTMLInputElement)iel;
//What to implement here to trigger the event that should contain IHTMLEventObj pEvtObj arguement
}
thanks in advance and awaiting for the solution...
|
|
|
|
|
Is there a way to check if a user is typing in a specific process before sending PostMessage() to it? If so, could it detect PostMessage or SendKeys from another application too?
|
|
|
|
|
I am wanting to prevent more than 1 instance of this application from loading. But I need for it to also work in a terminal server. So I need to find a way of modifying this code to identify processes by individual user and not by the overall machine.
Any Ideas?
string proc = Process.GetCurrentProcess().ProcessName;
Process[] processes = Process.GetProcessesByName(proc);
Process[] processes = Process.GetProcessesByName(proc);
if (processes.Length > 1)
{
MessageBox.Show("The Assist Suite is alreay running");
Application.Exit();
}
|
|
|
|
|
|
this code below, show first 1 screen and if you close 'login screen' the 'new Form1' gets created and shown.
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new loginscreen.LoginScreen());
Application.Run(new Form1());
}
the code below works fine, but i would like to know witch property of the 'login' class i need to detect if the login window has been closed and finalize the class and then open the main window of the application (new Form1).
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
loginscreen.LoginScreen login = new loginscreen.LoginScreen();
login.Show();
if(login.
{
Application.Run(new Form1());
}
else
{
Application.Exit();
}
}
how to detect or witch property of the login class tells me the login window is closed.
kind regards
Bad = knowing 2 much
|
|
|
|
|
In my opinion ..... Set a variable then if the login is not succesful increment that variable .... if it is greater than 3 ...... call application.exit(); ..... Else call the other form.
|
|
|
|
|
well, i know how to do that.
i wanna know how to detect if a form closed in Main().
if i press the RED X of login and return to main() and continue or exit.
thank you and kind regards
Bad = knowing 2 much
|
|
|
|
|
Use ShowDialog instead ?
Or more like your first example, Run the login form.
In either case, you can have a public property on your login form to indicate a successful login.
Were I doing that, I'd have the property return something that Form1 will require to run.
You wouldn't want someone to use Reflection to run your app without logging in.
|
|
|
|