|
Hi:
I have developed a analysis program for my users which runs for about 10 min and takes up the CPU 100% solid. The GUI also goes dead when the user hits the execute button to run the analysis and doesnt respond again until the analysis is done. I would like to give the user an option (with a button for instance) so that he can toggle the program execution on and off so that if the program is running and he wants to to get a responsive PC for a few moments to say launch Excel he can pause this analysis program and then resume execution. Is there a way to do this? How would the button work considering the GUI goes dead while the analysis is running?
Thanks, Sam
|
|
|
|
|
You'll need to look into multithreading. You'll want to run your analysis on a seperate thread so that the GUI thread doesn't freeze up. Then it's a simple matter to add a stop or pause (or both) button to you GUI and use that to halt your analysis.
|
|
|
|
|
sir please tell me how to implement data sending through socket program and also what are protocol supported by C#
iftikar
|
|
|
|
|
Search for socket programming on this website or on Google, there are plenty of examples available.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Morality Apart from God
Judah Himango
|
|
|
|
|
Question: I don't know if that's possible but How do I create a new property item that shows on the Properties Window ?
Any idea ?
I'm creating a control which must be customizable since that component connects on a database, the developer will have to specify the database name he wants to connect and I want something simple like he set the database name on the Properties Window then the component does everything.
profissional@gmail.com
|
|
|
|
|
If you are deriving from Windows.Forms.Control, all properties should be visible in the property window in the VS.NET designer by default. You can change what category each property shows up under, and the descriptions thereof, by using the Description and Category attributes. You can prevent a property from showing up by using the Browsable attribute:
<br />
[Browsable(true), Category("Data"), Description("This is the connection string to the database.")]<br />
public string ConnectionString<br />
{<br />
get { return m_connStr; }<br />
set { m_connStr = value; }<br />
}<br />
|
|
|
|
|
How can I use C# to get the icon of a specific folder path? I know about using the win32 api call SHGetFileInfo, but all I can seem to get from this is the generic folder icon always--either open or closed.
What I want to get is the same icon that windows explorer shows. So I want the little photo sitting in the folder if it's the "My Pictures" folder etc. Same idea for folders where the user has customized the icon.\
Could someone point me in the right direction here?
|
|
|
|
|
I want to do the following thing:
I have a tabsheet with properties where a user can set the program option, configure some various data, ect...
Some parts (a specific panel that is on a tab) must be showed in a separate dialog.
In the application, there is a 'Edit' button. clicking on it brings up a modal dialog with the panel and a save button.
This because the option screen has lots of tabpages.
Jumping to the specific panel to let the user configure the option would be to messy. how would the user finds his way back to the page with the edit button and continue?
OK, so far, so good. Bringing the panel in a dialog is no problem
in the constructor of a 'edit'dialog, add the panel to the controls array.
Troubles start when the edit dialog is closed.
This will also close the panel on the option screen.
(a dialog will automatically close his child controls)
how can I prevent this?
Perhaps a better solutions to do this?
greetings,
Niko
|
|
|
|
|
Niko
Do you need this panel in multiple places? If not why not create a options class that holds all your options and pass a reference to the class to your modal dialog. Set the options in the panel from the class and if the user clicks ok update your class.
Hope this helps.
Kurt
|
|
|
|
|
thanks Kurt,
but the panel contains lots of databound controls.
in the panel, the user can manage his customers, products, ...
reading all this data in an option class would be inefficient.
I also don't want to implement the same funtionality twice.
The application would be hard to maintain if I do so.
I guess I need to create a copy of the panel on the dialog.
(cloning the object doesn't work on controls)
greetings,
Niko
|
|
|
|
|
You could always make the panel a control. Do you have a screen shot by chance?
|
|
|
|
|
making a usercontrol of the panel would make sense,
I'll try this one.
There nothing much to see on the panel
to edit a product:
About 10 databound text boxes
and 2 editable datagrids
are on the panel
Kurt,
thanks for you advice.
|
|
|
|
|
Hi
I am new to programming with outlook 2000 using C#. I wanted to iterate thru all the folders and their mail items.
For ex. the folders can be
Inbox,
Personal
Important
Jokes
....
Official
....
...
......
All i want is to go thru all these folders one by one and read the mails inside those.
Can some one helpme out, mainly for iterating the folders. I am able to read the messages in inbox by specifying the
NS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
but i dont want to do this. Hope you can understand what i am looking for.
With Regards
Vivaj
|
|
|
|
|
|
Ya, I am using MS Outlook 9.0 object library.
The idea behind this load a .pst file in outlook and read all the mails, not only from inbox but all other folders too. I am able to achieve reading folders in Inbox, i am able to load the .pst file, but i am struck in iterating thru all the folders. Hope my query would have been clear now.
With Regards
Vivaj
|
|
|
|
|
I have a problem with the Deserialize a xml string.
I have a object I serialize:
MemoryStream buffer = new MemoryStream();
System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(myobject));
xmlSerializer.Serialize(buffer, schedule);
if I Deserialize the object after this code line, it works fine. But if I store the xml in code it Deserialize it gives me an error.
XmlDocument doc = new XmlDocument();
doc.Load(buffer);
string xml = doc.OuterXml;
XmlTextReader xmlreader = new XmlTextReader(xml);
schedule = (ScheduleDefinition) serializer.Deserialize(xmlreader);
I need the xml string as a parameter, so i need to be able to convert it back into the object. But I always get the message:
{"There is an error in XML document (1, 426)." }
Any other suggestions to accomplish this?
|
|
|
|
|
It sounds like your trying to serialize a string that contains xml using an xml serializer. I've never tried that before, but I have the suspicion that you might have some problems with that. Primarily, if your xml string contains the xml file header (i.e. ), and its embedded in the middle of another xml document, then you will get an error when the parser tries to read that "string". You can only have at the top of an xml document, and it can not exist anywhere else. XML inside XML might be your problem (although I can't guarantee it).
|
|
|
|
|
Hi buddies,
I have discovered something so interesting to myself! Wana share this top secret discovery! here:
We all know that 'lock(lockObject) {...}' causes no more than one thread can enter the block of code (Critical section). I always thought about the argument 'lockObject' that was usually 'this' and its usage while it seems the lock functionality doesn't care about what that argument is.
Recently I concluded the argument is so so important and it has a major usage and that is it lets us create critical sections that are not just one single code block, and different code blocks in different methods even in different classes may construct ONE critical section that no more than one thread may exist in the whole section.
I mean we can group various code blocks into unique critical section by assigning a single object reference as their lock(lockObject) argument. And also one great result is that we can create different critical sections in one class by assigning different lock arguments instead of 'this'; and these sections are independent.
So all you already knew this?! ok but atleast please agree that it is not well documented in MSDN or perhaps it is, but I have never seen it explicitly in the sections discussing lock statement.
Thanks for your note,
- Mohammad
My test console application code:
using System;
using System.Threading;
namespace TestConsole
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
private static readonly object _lockObject1 = new object();
private static readonly object _lockObject2 = new object();
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
Thread t1 = new Thread(new ThreadStart(Method1));
Thread t2 = new Thread(new ThreadStart(Method2));
Thread t3 = new Thread(new ThreadStart(Method3));
t1.Start();
t2.Start();
t3.Start();
Console.ReadLine();
}
static public void Method1()
{
lock(_lockObject1)
{
// critical section 1
for(int i = 0; i < 20; i++)
{
Console.WriteLine("Thread:1 " + i);
Thread.Sleep(100);
}
}
}
static public void Method2()
{
lock(_lockObject1)
{
// again critical section 1
for(int i = 0; i < 20; i++)
{
Console.WriteLine("Thread:2 " + i);
Thread.Sleep(100);
}
}
}
static public void Method3()
{
lock(_lockObject2)
{
// critical section 2
for(int i = 0; i < 20; i++)
{
Console.WriteLine("Thread:3 " + i);
Thread.Sleep(100);
}
}
}
}
}
---
"Art happens when you least expect it."
-- modified at 19:53 Wednesday 9th November, 2005
|
|
|
|
|
Actually, it's recommended you never use lock(this) [that is, locking the class instance] or lock(typeof(TestConsole)) [that is, locking the class type itself). It is highly recommended that if you do use locks, then you should lock private variables in your class, rather than class instance or the class type. The reason is that by using private variables to do locking, you have knowledge of and can control everyone that holds locks on your object. This would not necessarily be true for locking a class instance or the class itself.
Also, as an FYI, the C# lock statement is just syntax candy:
lock(_lockObj)
{
Console.WriteLine("hello!");
}
will get compiled down to:
System.Threading.Monitor.Enter(_lockObj);
try
{
Console.WriteLine("hello");
}
finally
{
System.Threading.Monitor.Exit(_lockObj);
}
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Morality Apart from God
Judah Himango
-- modified at 11:20 Wednesday 9th November, 2005
|
|
|
|
|
I agree with Judah, locking 'this' or the class itself is very bad practice, and leads to a lot of problems. Standard practice is to use a semaphore, or a synchronization root object, as a lock target. Some simple examples of good locking can be represented by a synchronized collection, or the singleton object:
A singleton:
public class MySingleton
{
#region Singleton Pattern
private static volatile MySingleton m_instance;
private static object m_syncRoot = new object();
public static MySingleton
{
get
{
if (m_instance == null)
{
lock (m_syncRoot)
{
if (m_instance == null)
{
m_instance = new MySingleton();
}
}
}
return m_instance;
}
}
#endregion
}
Synchronizing a collection:
public class MyCollection: CollectionBase
{
private class MySyncCollection: MyCollection
{
internal MySyncCollection(MyCollection col)
{
m_col = col;
m_root = col.SyncRoot;
}
private MyCollection m_col;
private object m_root;
public override object SyncRoot
{
get
{
return m_root;
}
}
public int Add(object item)
{
int index;
lock (m_root)
{
index = m_col.Add(item);
}
return index;
}
}
private object m_syncRoot = new object();
public override object SyncRoot
{
get
{
m_syncRoot;
}
}
public int Add(object item)
{
return List.Add(item);
}
public static MyCollection Synchronized(MyCollection col)
{
if (col == null)
throw new ArgumentNullException("The specified collection is null. Can not synchronize a non-existent collection.");
return new MyCollection.MySyncCollection(col);
}
}
|
|
|
|
|
Thank you for your replies friends,
While I am completely agree with your notes, I should say the concept I talked in my post was not a question about using or not using 'this' as the lock object.
That was something interesting that I didn't know up to know and that is grouped locks (with a single lock object) togather that construct composite single critical sections, and creating INDEPENDENT critical sections by assigning different lock objects.
I am excited about this because I didn't knew this before and non of my friends, thought so about lock usage. I posted here to see if anyone else see this interesting and usefull.
---
"Art happens when you least expect it."
|
|
|
|
|
how to download a file from a server using FTP through ASP.NET/C#
|
|
|
|
|
|
Hi,
I have found a C# control that I would like to use my in my commercial application. The control is distributed as a single C# source file which I have included in my project, i.e., my application will not link to an assembly or dll. It is licensed under LGPL or CPL (Common Public License), whichever suits the user (me) best. I would simply like to know if it is ok to do so and what I have to do to comply with the license I choose (e.g. include license terms)?
If there is somebody out there who can give me a quick answer, you can save me a few days trying to understand what those license files you never care to read actually means.
/Johan
|
|
|
|
|
hi . i want to manipulate exe files that when click on exe file before running ,it check some condition
and if it is true the file is run otherwise , the exe file close
thanks.
hdv212@yahoo.com
|
|
|
|