|
I do my homework. and I met this.
there are 3 forms in the project. in the 3 one is the main form 2 is the sub. and in the sub form I want to use some variable in the main form. for example in the main for have a connection object variable when the main form loaded the connection object created. and I open another one sub form and I also want to use the main form's connection object. and I do know how to do it.(all this I do it in C#)
Please give me some idea!
thanks!
|
|
|
|
|
Hi - search the forums. This question must be posted at least once a week.
Try clicking here...[^]
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
|
|
|
|
|
See this article on passing values between forms (or any related classes for that matter): http://www.codeproject.com/dotnet/passingvaluesbetweenforms.asp[^]
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
Has someone already create a TreeView control (or a listview with tile style) with the possibility to insert an element (node or row) with double row? (like the windows xp's explorer on certain type of file)
I explain better
open explorer, go in a folder with some MP3s, set the view in Tile (title) mode: All files are rapresented with more than one row (filename in the first; artist in the second and album in the third)...
i have to do a listview like this!!
|
|
|
|
|
hi..
don't you mean multiple columns?
if so, you can set the View - Property of you Listview to System.Windows.Forms.View.Details
greets
M@u
|
|
|
|
|
nono.. 2 rows!
see example:
http://aycu12.webshots.com/image/21971/2000690791167390529_th.jpg
|
|
|
|
|
Hi all
I am new to MSMQ.I have an application which sends a message.This message will be recieved by another application and stores in a MSMQ.And then it will read from the msmq and sends to some other process.Now the thing i am facing is that i have a recieve thread which starts at the application_start event .inside this thread i am calling the receive method of msmq.and i am using the follwing code with timespan
msg = mq.Receive(new TimeSpan(0,0,100));
now i know after 100 ms it will show MessageQueueException.my doubt is that what should i do after i catch the exception,because i want the thread to abort only at the application_end.so what should i do if a exception occurs.
Thanks in advance.
Regards
DilipRam
|
|
|
|
|
ramdil wrote: what should i do if a exception
What do you want your app to do? wait for another message? do nothing until the app exits?
|
|
|
|
|
Yes it should wait for message to arrive.
actually since i have started my thread on application , then the recieve method will get time out after the span of time ,it will throw messaging exception..so my doubt is in this exception section, i again need to wait until message comes
Regards
DilipRam
|
|
|
|
|
so catch the exception inside of a while loop:
while (listenForMessages)
{
try
{
msg = mq.Receive(new TimeSpan(0,0,100));
listenForMessages = false;
}
catch (MessageQueueException ex)
{
}
}
|
|
|
|
|
Thanks for the reply. i dont want to catch the exception.i want it to listen again..so what should i do..if i move a thread to sleep(100) in exception, will it serve my purpose. i am pasting my code section.
while (IsMessageRecieved)
{
try
{
mq = new MessageQueue(XMLMSMQRecievePath);
msg = mq.Receive(new TimeSpan(0,0,100));
XMLMSMQFileName = msg.Body.ToString();
}
catch (System.Messaging.MessageQueueException ex)
{
Logging.TraceError(ex.Message);
mq.Purge();
Thread.Sleep(100);
}
Regards
DilipRam
|
|
|
|
|
I'm not quite sure that I fully understand you. If you don't catch the exception then the program will explode. From the code segment posted, it looks like you want to read the first available message from the MSMQ and store the body of it in the variable "XMLMSMQFileName" and for each 100 ms that no message is received log an error . . . is this correct?
If so there are a few things to note:
1) there's no need to set mq to a new MessageQueue in each iteration of the loop. setting it once before the loop should be sufficient
2) if the timeout expires and the exception is thrown that means there are no messages in the queue, so calling Purge() is unnecessary
3) IsMessageRecieved needs to be set to true or else it will keep reading messages from the queue
|
|
|
|
|
Thanks for the reply.yes..it will wait for 100ms then not will go to exception.but i dont want to set the flag value to change,because what i want is that if the error occurs, then it should again wait unitl message comes..
so i am asking that if i am adding thread.sleep(100) will serve my purpose
..that means what actually i want is that on exception i dont want to exit the loop but should wait for the mssage to arrive..
will my code will satisfy if do sleep(100).hope i am clear with my requirement
Thanks in advance
Regards
DilipRam
|
|
|
|
|
no, Thread.Sleep won't do what you want, all it'll accomplish is to make the Thread wait for 100 more ms before it executes the next iteration of the loop. The way that it is currently written it will accomplish what you're describing, but you still need to add the line "IsMessageRecieved = false; " into the try block after the message has successfully been read like this:
try
{
msg = mq.Receive(new TimeSpan(0,0,100));
XMLMSMQFileName = msg.Body.ToString();
IsMessageRecieved = false;
}
catch . . .
this will make it so that if a message is received successfully then IsMessageRecieved will be set to false and the while loop will be exited but if the Receive method times out then the line IsMessageRecieved = false; is skipped and the loop is repeated
Last modified: 10mins after originally posted -- corrected IsMessageRecieved = true; to IsMessageRecieved = false;
|
|
|
|
|
Hi first of all thanks for detailed description,i understand what you are telling me but the think here is that i calling this method in a thread.thread starts at appn_start and thread stops at appn_end and here only i setting the variable value IsMessageRecieved=false..so that when ever my application is running mode, it will always check whether any message is in msmq then it will read..if i am setting flag variable inside the iteration, then once it is read then it will not listen...hope u understand my requriment.in this context ,will my code work with out any problem..this is my doubt
Regards
DilipRam
|
|
|
|
|
You're absolutely correct! I was thinking that you were reading only one message; the way you've described it sounds like you have it set up correctly to continue reading messages until the application ends, so it should work fine.
Just like before though, it's probably a good idea to set the IsBackground property to true on the Thread object so that it doesn't hang up you application when it's closing. Things should work fine even if you don't do this, but it probably won't hurt to throw this in just in case.
|
|
|
|
|
Thanks for the reply
Regards
DilipRam
|
|
|
|
|
Hello everyone,
I have got a webpage, a webservice and a client program. Is it possible to, when something changes in the webpage the webservice sends a method call with some parameters to the client program and the client starts to execute whatever method is called ?
Best regards...
.:: Something is Wrong ::.
|
|
|
|
|
Yes, but not easily. The browser is a sandbox, so you can't do this client side, as you rightly assumed. You would need to install a listener on the client, listening to a particular tcp port. The web page, would then post back to the server (or call a webservice) which would, via remoting calls, connect with the listener on the client. The remote and client side need to be 'aware' of each other, ie names, ports etc.
Read Nish's article here[^] to get a basic understanding of what can be achieved.
This will only work on a LAN / Intranet unless you want to do battle with firewalls etc.
I've just done something very similar today....I've used it to implement a sign in / sign out deputy system. If the current 'on call' support signs out, the webserver sends a message to the next support person on the rosta. A small exe on there machine is listening on a particular port for this call and pops up a message. Saves them constantly checking the webpage.
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
|
|
|
|
|
Thanks for your help. I think we can overcome the firewall problem by configuring all firewalls where the clients are installed.
But I like your approach to the problem. May be I should try it.
When the page refreshes and there are some changes the webservice sends a message to a specified ip and port and when the client receives this message the method starts to work.
The only problem is what if we have more than 1 method.
Well then we may specify more messages, each message can invoke one method so a simple switch statement should do the job
Hmm..
Sounds simple and it should work.
Thank you very much...
.:: Something is Wrong ::.
|
|
|
|
|
pashje wrote: The only problem is what if we have more than 1 method.
This is the server side portion....
IMyChecker checker = (IMyChecker)Activator.GetObject(
typeof(IMyChecker), "tcp://localhost:9000/CheckListener");
checker.RunMethod1();
checker.RunMethod2();
Here, CheckListener is the name of the class on the remote machine. checker is an instance of that class, and can now call any exposed methods.
I'm no expert on this, as I've only picked this stuff up today, so DO check out what I've said, but the above works for me.
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
|
|
|
|
|
Hello,
I would like to know what lines in c# replace the following lines in C++:
LCID lcid = ::GetUserDefaultLCID();
m_lcid = LANGIDFROMLCID(lcid);
Thanks!!!
|
|
|
|
|
use the System.Globalization.CultureInfo class. The user default is, I think, System.Threading.Thread.CurrentCulture.
-----
If atheism is a religion, then not collecting stamps is a hobby. -- Unknown
|
|
|
|
|
|
Hai Everybody,
Can any one please tell me how to debug the windows service even though i used the try catch block i couldn't find out the error point please give me solution to overcome this problem.
Best Regards,
M. J. Jaya Chitra
|
|
|
|