|
Jeez - You get impatient after only half an hour. Perhaps, if you need the information this fast, you might want to pay for a support call to Microsoft. Here you will get help by volunteers who help out when they can, not at your whim.
|
|
|
|
|
You've been here for over two years, so you should know how a forum environment works by now. Making a demand like this after waiting only 30 minutes is just ludicrous.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I am working on one app
Ihave one gridview where i write information but when i restart my app the informations are gone!!??
Help me !!!!
Please!!!!
Thanks
nemanja
|
|
|
|
|
You will need to persist the data somehow.
That is, when a new row is added you need to find some method to take the data contained within that row, and store it somewhere. That could be a database, xml file, plain text file or something else - it's up to you, you're the developer. It's not excel.
|
|
|
|
|
I have a class assembly that references the IMB WebSphere MQ system. I have to register the MQ one time before I can start making calls. I would like to do this when I load my class assembly. What's the best way to achieve this?
Tanks
Phil
|
|
|
|
|
You can do this in the class constructor (or a static constructor) as long as you put the appropriate safegaurds in place.
You want to make sure that once MQ has been registered you don't try to do it again. You also want to make sure that if the registration fails, your constructor doesn't throw an exception but sets the class state in such a way that the class is created but not usable. Throwing an exception in the constructor will result in a very ambiguous "Type initialization failed" error message.
The better way would be to create a singleton class that manages the relationship with MQ. The singleton is instantiated once in your class constructor. It would need to provide an explicit "register" method, and any other methods that access MQ would be part of this singleton and can take advantage of the register method implicitly. The benefit here is that everytime you make a call to MQ, the system verifies that MQ has been registered, and if not registers it before making the call.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
I had thought about that approach. I'm trying to eliminate the need for the user of my library to initialize the library (hiding the details). It's almost like the global.asax file - with the Application.Start event. If there was an Assembly.Load event or something similar that i could hook into, so the initialization could be done automatically.
Phil
|
|
|
|
|
There aren't any equivalent events like Assembly.Load. It still sounds like the best approach would be to implement a singleton MQManager class. Since it is a singleton you can hide all of the initialization details behind an explicit Register method. Each "normal" method can check the state and initialize as needed.
Something like this (rough pseudo-code):
public class MQManager {
private bool registered;
public void Register() {
if (!registered) {
registered = true;
}
}
public void AddMessage() {
Register();
MQ.Add();
}
}
Since the Register function protects itself from registering more than once through the registered flag, it is safe to call multiple times. Also, since the AddMessage function makes a call to Register before doing anything else, it is safe to be called by the user without having first explicitly called Register .
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
I appreciate the help.
If that's what I got do - then that's the way I'll go.
Tanks
Phil
|
|
|
|
|
well, i have a timer initilized and started in the Form constructor :
tmpTimer = new System.Timers.Timer(1000);
tmpTimer.Elapsed += new ElapsedEventHandler(tmpTimer_Elapsed);
tmpTimer.Start();
the timer start in the form constructor and keep checking a bool variable(doThing),
if this variable is set to true in the program, the timer excute the event handler,
private void tmpTimer_Elapsed(object sender, ElapsedEventArgs e)
{
if (doThing == true )
{
MessageBox.Show(doThing.ToString());
}
}
but i want the event handler to excute only once(at the time that doThing is set to ture
, so i add one line of code to change the value of doThing to false,to prevent excuting
of the event handler.
private void tmpTimer_Elapsed(object sender, ElapsedEventArgs e)
{
if (doThing == true )
{
MessageBox.Show(doThing.ToString());
doThing = false;
}
}
but the poblem it's that the value of doTing dose not changed, and messageboxes keep
showing in screen every one second (with True printed on them) till i close one of
them, then they stoped showing.
what i want is to prevent timer from entring if block by changing doThing to false.
i don't know what is realy happened there, any gusse or suggestion would be helpfull,
thanks in advance.
|
|
|
|
|
MSDN states: "The Elapsed event is raised on a ThreadPool thread. If the processing of the Elapsed event lasts longer than Interval, the event might be raised again on another ThreadPool thread."
Since the MessageBox.Show method is a blocking method, doThing is true until you close the first message box, and the execution of the event handler on additional Threadpool threads causes the appearance of a new message box every seconds.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
If you move doThing = false above the MessageBox.Show , there will be a small improvement, but there would still be a possibility of multiple message boxes.
You could try using System.Threading.Timer[^] instead and it provides a parameter to do one shot firing of the timer. Something like
void StartTimer()
{
int dueTime = 5000;
object state;
System.Threading.Timer timer = new System.Threading.Timer(new TimerCallback(TimerMethod), state, dueTime, Timeout.Infinite);
}
Passing Timeout.Infinite as the last parameter makes the timer run only once.
|
|
|
|
|
S. Senthil Kumar wrote: You could try using System.Threading.Timer[^] instead and it provides a parameter to do one shot firing of the timer.
The same can be achieved by setting the System.Timers.Timer.Autoreset property to false .
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
The documentation[^] on the property doesn't say that the timer will fire only once, it says that the Elapsed event will be raised only once, the first time the timer elapses. You could argue it's the same, but the OP has to write code to stop the timer.
|
|
|
|
|
|
In VB there is this out of focus even for a text box. Can some one tell me the equivalent for C#?
I would like to validate a value in the text box when we leave this text box.
Suggestions?
Thanks,Arun
|
|
|
|
|
mrarunks wrote: In VB there is this out of focus even for a text box. Can some one tell me the equivalent for C#?
It is the same framework, so it will have the same events (Unless, by VB you are talking about VB6 or ealier)
|
|
|
|
|
Enable the CausesValidation property and register to the Validating event.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
i need to write method and return somevalue from that method
for example return number
and use that number in the rest of application
ma_refay
|
|
|
|
|
From your question I can tell you need more help than can be provided here.
only two letters away from being an asset
|
|
|
|
|
Buy a book. C# Step By Step would be an excellent start.
Grady Booch: I told Google to their face...what you need is some serious adult supervision. (2007 Turing lecture)
http:\\www.frankkerrigan.com
|
|
|
|
|
ma_refay wrote: i need to write method and return somevalue from that method
for example return number
and use that number in the rest of application
You've been asking questions on this site for over a year now and you've only just got around to asking this?
public int SomeMethod()
{
return 1;
}
|
|
|
|
|
Please don't email me direct - I won't respond off line.
ma_refay wrote: how i call the return 1 in my form
or how to assign that return ti variable
int theValue = TheMethodThatReturnsOne();
|
|
|
|
|
I'm trying to send a mail through gmail using System.Net.Mail..but it's giving me errors. here's the code:
<br />
MailMessage msg = new MailMessage();<br />
msg.From = new MailAddress("jiminyjones@gmail.com");<br />
msg.To.Add("sharpie@usmarines.com");<br />
msg.Subject = "C# Mail Message!";<br />
msg.Body = "Hey Buddy!";<br />
msg.IsBodyHtml = false;<br />
SmtpClient b = new SmtpClient();<br />
b.Host = "smtp.google.com";<br />
b.Send(msg);<br />
I know the problem is with the authentication because gmail requires ssl, but i couldn't find a way to fix it (i tried "b.EnableSsl = true" but it didn't work).
|
|
|
|
|
I don't think gmail has an open SMTP relay.
You are not supplying a username or password for the smtp server to authenicate you.
Grady Booch: I told Google to their face...what you need is some serious adult supervision. (2007 Turing lecture)
http:\\www.frankkerrigan.com
|
|
|
|