|
What I mean from a non-grid view is a detail view, where the controls are individual controls on a form instead of a grid view.
Thank you,
Glenn
|
|
|
|
|
Hi
Does anyone have any decent links or documentation for non blocking TCP programming. I have a server that accepts incoming connections and processes requests from users but I cant get it working very well. Any help would be appreciated.
Thanx
|
|
|
|
|
|
When you accept you get a socket.
You process that socket in another thread. Either create one or use the thread pool.
|
|
|
|
|
Hello,
I've some list<string>, i would like to retrieve a sub list of a given list from 'startPos' till 'endPos'
how can i do that ?
thanks
|
|
|
|
|
If you are using List<T>[^] class then see GetRange[^] method.
If you are talking about a different kind of list then you need to elaborate a bit.
|
|
|
|
|
and after GetRange, i should Clone it ? (avoid shallow Copy)
|
|
|
|
|
igalep132 wrote: and after GetRange, i should Clone it ?
It depends on your requirements.
If you really need to avoid shallow copy, then you can make a deep copy on result returned from GetRange .
For this purpose you can use a generic method like this one:
public static T DeepCopy<T>(T obj)
{
object result = null;
using (var ms = new MemoryStream())
{
var formatter = new BinaryFormatter();
formatter.Serialize(ms, obj);
ms.Position = 0;
result = formatter.Deserialize(ms);
ms.Close();
}
return (T)result;
}
The code above should work for all serializable types.
modified on Thursday, May 13, 2010 10:49 AM
|
|
|
|
|
thanks
|
|
|
|
|
Dear experts,
I'm often creating a lot of small applications for learning some features of .net or for creation of small tools. I do this mainly, by creating a standard winforms-application with some buttons and e.g. some stupid text-controls hacking in the code; that's it.
But I continuously find out, that some of these small applications tend to evolve over time to some bigger projects and I get more and more problems for the update/extension/maintenance of my "hacking"-versions.
I experienced, that I always need the same standard-features during the evolution of these small app's.
Some of these features are:
--> Clear separation of View(Form) and Controller(AppLogic) and sometimes also Model (This actually is the ModelViewController-Pattern)
--> The Controller should run in it's own thread
--> Basic LoggingSupport
--> Basic support for updating the view by some event-like messaging
--> Getting some User-Feedback into the Controller (e.g. if a file is not found)
--> ..... and may be some more basic features .....
Creating these features for each application again and again consumes a lot of time.
My Question: Is there some small "Standard"-Framework available which supports my type of programming - may be via configuration?
Thanks
|
|
|
|
|
Assuming you are using a version of Visual Studio you should be able to create a new template from your project. Then when you need a new sample you can create it from your template.
It's time for a new signature.
|
|
|
|
|
Dear experts,
I want to update the configFile "app.config", but the "Save(..)" function does not work.
Surprisingly, if I use the "SaveAs(..)" function (storing the config to another file),it works
static void Main(string[] args)
{
Configuration config =ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings.Add("Modification Date",DateTime.Now.ToLongTimeString() + " ");
config.Save(ConfigurationSaveMode.Full);
config.SaveAs("Test.config", ConfigurationSaveMode.Full);
}
Question: What sense does the Save()-Method make?
Can somebody help me?
Thanks in advance
|
|
|
|
|
Is it throwing any error?Can you check if the file is readonly
|
|
|
|
|
No exception is thrown by the Save()-Method, the file is also not "read-only"
|
|
|
|
|
The app.config file is not updated during execution of application,but it would be writing a .xml document in the bin folder with applicationname.exe(Xml configuration File), and each time your file will be updated but not app.config
|
|
|
|
|
Sorry, of course, app.config is not expected to be updated, but I expect that in the bin-directory one of the files ".xx.exe.config" or "xx.vshost.exe.Config" should be updated at least. But none of them is updated.
I', puzzled. What's the purpuse of the Save()-Method?
Thanks for you kind replies
|
|
|
|
|
Hi
In my application, the Main form starts a thread in another class.
In this thread I need to show another form as modeless. If i call it in the thread, the form shows but in a hanged state. no controls are visible and it is in not responding state.
How can i achieve my requirement.
Please help.
Thanks.
|
|
|
|
|
Did you use BackgroundWorkerClass???
|
|
|
|
|
No.
It is a normal class whose object i'm using in mainform
|
|
|
|
|
Hi,
this article[^] deals with Controls and Threads.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
You have to create all your forms on the GUI thread, of which there can only be one in the application.
I suggest you invoke a method back onto the Main Form thread to create the new modeless form.
|
|
|
|
|
I tried calling a delegate.BeginInvoke in the thread for the main form in which i called the new form.show. but same results. the new form is in hanged state.
|
|
|
|
|
BeginInvoke is not needed as the Show is not going to block any threads. Just call MainForm.Invoke with the delegate to show the newForm. eg.
Thread thread = new Thread(new ThreadStart(StartNewThread));
thread.Start();
}
void StartNewThread(){
this.Invoke(new MethodInvoker(this.LaunchForm2));
}
void LaunchForm2(){
Form2 frm = new Form2();
frm.Show();
}
I know as a standalone example my code would be daft, why start a new thread just to invoke back to the original thread, but I assume you are doing some other processing in the secondary thread to make it worthwhile.
|
|
|
|
|
I'm not sure about the best practices where this is concerned. It's not something I would ever do so I haven't investigated and could maybe have some disasterous consequences. A quick test however reveals it works - I'm sure others will comment!
using System;
using System.Threading;
using System.Windows.Forms;
namespace Forms_Test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Load += new EventHandler(Form1_Load);
}
private void Form1_Load(object sender, EventArgs e)
{
Thread thread = new Thread(new ThreadStart(StartNewThread));
thread.Start();
}
private void StartNewThread()
{
Application.Run(new Form2());
}
}
}
Edit: This MSDN[^] link may be of interest.
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)
|
|
|
|
|
It works, but ugh!
The main message loop that started Form1 will end when that closes, fire any application clean-up code you wrote and leave Form2 orphaned.
It is a bit like firing up another application using Process.Start . Form2 would have to be treated as a separate application and the start thread must do all the usual stuff you need to run, and shut down an application. On the down side, they would reside in the same AppDomain and a crash in either thread would then kill both, also communication between the parts would be a nightmare.
I'm not sure how they manage it, but I guess Office does something similar for Word and Excel etc. where it appears to fire up a new instance of Word for each document, and they can be closed independently, however only one process is running.
Interestingly in the browser world things are moving the other way, eg. Google Chrome runs each tab in a separate Process, so you get one apparent application but multiple processes!
|
|
|
|