|
Hi,
Please excuse the lack of code. I don't have the source with me.
I'm builing an Server-Client based system and it's the first time I'm working with threading and socketing.
My UdpClient has a listener that's constantly waiting for incoming messages on a specific port. That listener runs on a seperate thread, which is defined in the class and the listen() method is handed as a new Threadstart.
Inside the method, the while loop checks if the application must continue listening before preparing to receive messages.
My problem is that when my application closes all the code terminates and runs out the bottom. But when I open Program Manager the process is still running and if the application starts again the port is already in use. Thus I must deduce that the listener thread did not terminate.
I tried calling the .Abort() method and it seems to work, but I can't manage to close the application completely.
My question is this: Is there a way to get a list of all threads started by my application and to terminate them manually?
Or alternatively: Is there a way I can force my application to terminate itself and all its threads?
"Build an idiot-proof application, and the world will create a bigger idiot."
|
|
|
|
|
Assign true to the IsBackground property of your thread.
"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
|
|
|
|
|
Thanks. Will try that.
Respect for 1-upping my signature...
|
|
|
|
|
OK, I did what you suggested and it worked like a charm, but I've now run into a problem of another kind.
I know that timers and multithreading don't really go together, but my app was working perfectly with 3 timers doing different things.
As soon as I made that thread background, 2 of the 3 timers stopped funtioning. They start and enable fine, but the tick event never fires.
After looking through the articles on here I can't find anything to solve my problem. Basically what I need is:
If there is no mouse movement for 20 seconds, hide a specific panel control.
Is there and easy way to do this?
|
|
|
|
|
For the need of one my application I have been numerously advised (here, on CodeProject) to use the Policy Manager.
But... the problem is.. I don't know what it is!
I have XP Home edition.
I looked in the Control Panel and the Accessories and I can't find it!
Where is it?
what is it?
On top of that it's to write an app for a dad wanting to monitor his kid.
I'm not sure this 'arcane' policy manager is the right solution...
|
|
|
|
|
Policy manager is hardly 'arcane'...
Obtuse, yes. Frustrating, yes. Arcane no.
I have never used XP Home Edition, only Professional, so cannot guarentee it is included in Home Edition.
Start -> Run -> MMC.exe <enter>
File -> Add/Remove Snap-In -> Add -> Group Policy Object Editor <ok> <ok>
As I do not know what you are trying to do, I cannot offer you any alternatives.
|
|
|
|
|
Thanks!
Now I have to experiment....
|
|
|
|
|
Hi all,
I try to programm a which captures a part of the screen. It works. But the form border type is sizable: That doesn't look good. If I set the form border type to none the form isn't sizable and movable. Is there any solution?
thanks for helping
dolce
btw: is it possible to set the opacity of an button or picturebox to 100% if the form by itself is semi transparent?
|
|
|
|
|
|
Thanks a lot this article would help in the future. I've found a solution which is very easy. In short:
* Create a form -> border none -> set the opacity of the form as you like.
* Define the events onMouseDown, onMouseUp and onMouseMove
* onMouse down set a bool to true, onMouseUp to false
* onMouseMove calcutate the new position of the form
* create a pictureBox in the lower right corner
* Define the events onMouseDown, onMouseUp and onMouseMove
* onMouse down set a bool to true, onMouseUp to false
* onMouseMove calcutate the new size of the form
That's all!
dolce
|
|
|
|
|
hi all
I am developing windows application, where i have login, other options pages,
In the main page i checking for the user idle time(in a timer), if the user idle for certain period i should display logout page and close the modal dialogs which is being displayed by the other pages.
For modal forms i am storing the current openned form in mainpage's object
during time out i will close the opened forms using this object's Close method,
But how can i close the messagebox which is displayed in other pages during logout. Is there any way that the mainpage can close or control the messagebox which has been displayed by other pages
note: Here pages are various user controls which willl be loaded on the Mainform's panel
Thanks and Regards,
Srini
|
|
|
|
|
write
Application.DoEvents();
before writeing
this.Dispose(); or this.Close();
|
|
|
|
|
What is suppose to dispose here either that user control or main form itself,
If i dispose the user control will it close the user control's message box.
I want dispose only the messagebox, not the user controls,
am i clearly explained situation?
|
|
|
|
|
You can't close the messageboxes, at least not easily. Make your own dialog box to use as messagebox, so that you can control it.
---
b { font-weight: normal; }
|
|
|
|
|
Don't reinvent the wheel, all the hard stuff for a timeoutable messagebox clone was already done here. I wrote a MessageBox esque wrapper because I didn't like the provided controller, it took about a day to do. Having a unique name for each messagebox and suffing them all into a single container probably would make things easier for localization.
http://www.codeproject.com/cs/miscctrl/MessageBoxEx.asp?df=100&forumid=155440&noise=2&mpp=50&select=1661227&msg=1661227
|
|
|
|
|
hi.
i want to set button.Image Property by APPLICATIONS.ico that save as resource in My VS2005 as follow but an error occured when compiled my app :
in Form1_load event :
Bitmap _bitmap = global::AmlakButtons.Properties.Resources.APPLICATIONS; <br />
System.IO.MemoryStream _stream = new System.IO.MemoryStream(); <br />
_bitmap.Save(_stream,System.Drawing.Imaging.ImageFormat.Bmp);<br />
<br />
System.Drawing.Size _size = new Size((btn_fish.Width / 2) - 20, btn_fish.Height - 5); <br />
ImageList list = new ImageList();<br />
System.Drawing.Icon _icon = new System.Drawing.Icon(_stream,_size ); -> Error in this line<br />
System.Drawing.Image _image = Image.FromStream(_stream,_size ); <br />
list.Images.Add(_icon);<br />
btn_fish.ImageList = list;<br />
btn_fish.ImageList.ImageSize = _size;<br />
btn_fish.ImageList.TransparentColor = Color.Black;<br />
btn_fish.ImageIndex = 0;
but when i use _image in list.Images.Add(_image); my Program worked correctly but bacause set btn_fish.ImageList.TransparentColor = Color.Black; the black color of icon will be removed .
How to solve my problem ?
|
|
|
|
|
I have a form that i instanciate via Reflection from an external Assembly. My problem is that i need to execute some methods implemented in that form by an interface.
|
|
|
|
|
If you are able to include the source of the interface or reference the assembly which defines the interface you can create a variable of the interface type and simply cast the object instanciated via reflection.
Otherwise go on using reflection to invoke those methods (Type.GetMethod , MethodInfo , Type.InvokeMember ).
"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
|
|
|
|
|
Tank you for your reply.
I already did the second way but i want to try the first way to make my choice.
How can i create the object and I realize the cast?
Can you help me?
|
|
|
|
|
Assuming your interface is named "IMyInterface" you will have something like:
IMyInterface var = (IMyInterface) Activator.CreateInstance(formType); with formType being the type object of your form.
"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
|
|
|
|
|
Hi,
I am working on a C# WinForm application which allows user to compare items by entering a numeric value.
Can anyone suggest how to implement such a component like the following?
----------------
| - | A | B | C |
----------------
| A | X | 1 | 3 |
----------------
| B | X | X | 8 |
----------------
| C | X | X | X |
----------------
A,B,C, are the items to compare and the numbers are weight for the paiwise compairson
between two items.
Regards,
Edwin
|
|
|
|
|
Hi!
I load names and values into a listbox. I sorted the listbox. Is there anyway to make the highest value to appear first? I should work as a highscore board. Only the 10 best scores should be displayed. Any suggestions?
namn is name and procent is the score:
while ((line = sr.ReadLine()) != null)
{
for (int i = 0; i < 1; i++)
{
varden = line.Split(' ');
Procent = Convert.ToDouble(varden[0]);
Namn = varden[1];
listBox1.Items.Add(Procent + " " + Namn);
listBox1.Sorted = true;
}
}
Newbie untill I die!
|
|
|
|
|
Hi ,
i want to use USB for reading and writing the data in VC#.Net 2003 and framework 1.1
How can i access that
plz help on this topic
Thanks
|
|
|
|
|
You really need to be more specific. Are you wanting to read and write data onto a USB flash drive, you merely have to address it as any other drive.
Otherwise, you need to access it through the API of the driver, or write your own driver for the hardware. Check with the hardware manufacturer for a development kit.
|
|
|
|
|
Hi! i want to retrieve data from clipboard. for this i m using code of line.
System.Windows.Forms.IDataObject clipboardData = System.Windows.Forms.Clipboard.GetDataObject();
this code run on windows server 2000 successfully. but on windows server 2003 it is thrown an exeption: Requested Clipboard operation did not succeed.[System.Runtime.InteropServices.ExternalException]
please help me.
Amit Kuamr Pandey
|
|
|
|