|
log off
|
|
|
|
|
thanks Luc, as far as I know, network connections goes after logging off. this is an internet cafe software so I need the network connection to be able to open a new account for the new user. Any other way?
|
|
|
|
|
How about this: take a list of process IDs before the user starts; kill every process not in the list when the user is done.
|
|
|
|
|
yes you're right! Thank you very much!
|
|
|
|
|
you're welcome.
|
|
|
|
|
hi Luc, I didn't wanna post a new question as this is the same issue.Could you please see below code and say where I'm doing wrong? Briefly, I just want to get the processes that are run after my form loaded. Thanks.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Process[] processesBefore;
Process[] processesAfter;
private void Form1_Load(object sender, EventArgs e)
{
processesBefore = Process.GetProcesses();
}
private void button1_Click(object sender, EventArgs e)
{
processesAfter = Process.GetProcesses();
CompareProcesses compare = new CompareProcesses();
IEnumerable<Process> theDifference = processesAfter.Except(processesBefore, compare);
foreach (Process p in theDifference)
{
listboxDifference.Items.Add(p.ProcessName);
}
}
}
public class CompareProcesses : IEqualityComparer<Process>
{
public bool Equals(Process x, Process y)
{
return (x == y);
}
public int GetHashCode(Process obj)
{
return obj.GetHashCode() ^ obj.GetHashCode();
}
}
|
|
|
|
|
Hi,
a Process is an object that describes a process (note the leading capital). When two Processes are the same, so are the processes; when two Processes are different, they can still point to one and the same process. So you have discovered GetProcesses creates an array of all new Process instances...
I did suggest you compare process IDs, as those are unique; your code doesn't do that.
|
|
|
|
|
|
you're welcome!
|
|
|
|
|
hi Luc, can I ask one more minor question? I don't see the open file browser windows among the processes and so I can't close them. Are they not process? How can I close them?
|
|
|
|
|
|
ok, here goes, i have been stuck on this for hours and getting no further so i thought i would ask you lot ....
ok basically all this program is doing is when something is entered into txtfind (on form frmfindandreplace [form 2] ) it will be then pasted into a richtextbox ... this is named InsertText. This is on form 1 of course ... so i am transferring the string from frmfindandreplace to form 1...
here is my code...(i have edited it to make it smaller so that you can see my problem more clearer)
frmFindReplace
public string findme
{
get { return txtfind.Text; }
set { txtfind.Text = value; }
}
private void bnFind_Click(object sender, EventArgs e)
{
if (Clicked != null)
Clicked(true);
}
Form 1
public frmFindReplace frmFindReplace{get;set;}
public window()
{
void find_Clicked(bool Yes)
{
InsertText(frmFindReplace.findme);
}
}
thanks for all your help ... i keep getting the error message about it being a null value .... why ?
|
|
|
|
|
did you set frmFindReplace property ?
if yes, you should show InsertText code
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
That is because the property frmFindReplace is null. Are you setting that property somewhere?
How are you opening the FindReplace form? You will need to keep that instance of the form in the Form1 to access the correct value of the property findme in the form1.
|
|
|
|
|
how do i store the property ?
and i am opening the form as follows :
private void findAndReplaceToolStripMenuItem_Click(object sender, EventArgs e)
{
frmFindReplace find = new frmFindReplace();
find.Clicked += new ButtonClick(find_Clicked);
find.ShowDialog();
}
|
|
|
|
|
There's a few things that you haven't shown that could be the problem but rather than guess at that I would suggest an easier way. Why not just raise an event and pass the text in the arguments back to the main form? Something like...
using System;
public class TextEventArgs : EventArgs
{
private string text;
public TextEventArgs(string text)
{
this.text = text;
}
public string Text
{
get { return text; }
}
}
using System;
using System.Windows.Forms;
public partial class FormFindAndReplace : Form
{
public event EventHandler<TextEventArgs> FindClicked;
public FormFindAndReplace()
{
InitializeComponent();
}
private void buttonFind_Click(object sender, EventArgs e)
{
OnFindClicked(new TextEventArgs(textBox.Text));
}
protected virtual void OnFindClicked(TextEventArgs e)
{
EventHandler<TextEventArgs> eh = FindClicked;
if (eh != null)
eh(this, e);
}
}
using System;
using System.Windows.Forms;
public partial class FormMain : Form
{
private FormFindAndReplace formFindAndReplace = null;
public FormMain()
{
InitializeComponent();
}
private void findAndReplaceToolStripMenuItem_Click(object sender, EventArgs e)
{
if (formFindAndReplace == null)
formFindAndReplace = new FormFindAndReplace();
formFindAndReplace.FindClicked += formFindAndReplace_FindClicked;
formFindAndReplace.FormClosing += formFindAndReplace_FormClosing;
formFindAndReplace.Show();
}
private void formFindAndReplace_FindClicked(object sender, TextEventArgs e)
{
Console.WriteLine(e.Text);
}
private void formFindAndReplace_FormClosing(object sender, FormClosingEventArgs e)
{
formFindAndReplace.FormClosing -= formFindAndReplace_FormClosing;
formFindAndReplace.FindClicked -= formFindAndReplace_FindClicked;
formFindAndReplace = null;
}
}
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Hi,
I am new to the singleton pattern. I read that it could be used to load all your website setting and configuration values. I also read that people avoid singletons, and people that do unit testing don't use singleton patterns. Why is this? Are singletons good to use in my scenario? If not, how should I do it then? And how can this be unit tested?
Thanks
Brendan
|
|
|
|
|
First since this is a web related question you should have used the ASP.NET or Web Development forums.
The singleton pattern is a tool like any other, it has its uses under the proper conditions to solve the proper problem. Since the web.config file contains the settings and configuration information for an ASP.NET app you are gaining nothing by trying to use a singleton. On the other hand if some settings are coming from a database, or other source, then a singleton instantiated by the application may be of use.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi,
My apologies for posting it here, but using it to get settings values was just an example. It was posted here because I had some questions regarding the design of the pattern. The main issue that I have is that there is some difficulty in unit testing it. How does one go about unit testing a singleton pattern, and testing all the methods in the .Instance property? Lets say I have something like:
BlogSettings.Instance.Name
How would I unit test .Name?
|
|
|
|
|
Use the Google [^]Pattern
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
The Singleton pattern is more for C++ and is not of much use in C#, especially since the introduction of static classes.
As for unit testing, I hear that they can make using mock objects difficult, but I'm not the one to ask about that.
|
|
|
|
|
PIEBALDconsult wrote: The Singleton pattern is more for C++ and is not of much use in C#
Got a source for that assertion?
|
|
|
|
|
That's my own conclusion.
|
|
|
|
|
I always use the singletom to save the system setting.
Because I never do the unit testing, I do not know why some people avoid singletons, perhaps there is better way than this.
|
|
|
|
|
How can i get MouseEventArgs in datagridview1_CellValidating cause i wanna to use this code in datagridview1_CellValidating:
if (dgvFactorSell.HitTest(e.X, e.Y).ColumnIndex <= dgvFactorSell.CurrentCell.ColumnIndex && dgvFactorSell.HitTest(e.X, e.Y).RowIndex == dgvFactorSell.CurrentRow.Index)
FlagIsBack = true;
private void dgvFactorSell_MouseClick(object sender, MouseEventArgs e)
{
if (dgvFactorSell.HitTest(e.X, e.Y).ColumnIndex <= dgvFactorSell.CurrentCell.ColumnIndex && dgvFactorSell.HitTest(e.X, e.Y).RowIndex == dgvFactorSell.CurrentRow.Index)
FlagIsBack = true;
}
modified on Sunday, June 20, 2010 1:47 PM
|
|
|
|