|
I use it as:
Form fPom=new Form();
fPom.ControlBox=false;
fPom.ShowInTaskbar=false;
fPom.StartPosition=FormStartPosition.Manual;
fPom.FormBorderStyle=FormBorderStyle.FixedToolWindow;
fPom.Deactivate += new EventHandler(this.fPom_Close);
fPom.Location ...
I open this form by Show() method and close it in Deactivate event (other events doesn't work good)
Hi,
AW
|
|
|
|
|
A.Wegierski wrote:
I open this form by Show() method and close it in Deactivate event (other events doesn't work good)
This works in some cases, but suppose it's a menu, and has submenus? When the submenu recieves focus, the original menu disappears.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Hi,
I am writing a multi-threaded program that involves concurrent access of ArrayList objects. Some threads need to read the list, while others need to modify it. Both operations must NOT occur at the same time, and none of the thread need read & write access. they are either reader / writer. actually, in my case, there's multi-reader and a single writer. How can i manage the access with SyncRoot or any other synchronization API in C#?
MSDN disnt provide much info...
Thanks.
|
|
|
|
|
viperxp wrote:
MSDN disnt provide much info...
Static members are often easily overlooked (Intellisense is partially to blame). Have a look at the ArrayList.Syncronized() that returns a thread safe wrapper for the arraylist that you passed to the method. I have never needed to use it, but that is how I understand it.
Hope this helps
<a TITLE="See my user info" href=http:
|
|
|
|
|
You may also want to look into locking the SyncRoot instance property.
|
|
|
|
|
I ahve looked at both the Synchronized() and the SyncRoot property in MSDN, but i dunno how to use them (to solve my problem) ... maybe can someone provide some hints on how can i use them to address my prob?
|
|
|
|
|
viperxp wrote:
I ahve looked at both the Synchronized()
The Synchronized() method returns an instance of an ArrayList which takes care not to let only one operation run at a time.
The SyncRoot property returns an object which you can use to do your own locking (by using the lock keyword for instance).
ArrayList syncList = ArrayList.Synchronized(theList);
...
And a second demo:
ArrayList theList = ...;
...
lock(theList.SyncRoot)
{
} I prefer using lock, because it makes it very obvious that the code within is protected instead of trying to trace your steps through code to see whether you forgot to create the Synchronized wrapper.
The only advantage I can think of using the synchronized wrapper would be if you were performing lots of operations in a row where it didn't matter if other threads accessed the list in between those operations.
James
"I despise the city and much prefer being where a traffic jam means a line-up at McDonald's"
Me when telling a friend why I wouldn't want to live with him
|
|
|
|
|
OK, let theList be the persistent copy (the one containing data that my app uses). is syncList an identical copy of theList, or just another reference to theList?
in my program, the threads will either read from or write to theList. Read & write operations will be mutually exclusive i.e. they cannot happen at the same time. when theList is being modified all reader threads must wait till the write is complete b4 they can read. Similar, the thread that modifies theList must wait till there's no read ops b4 changing theList.
There's multiple readers, but only 1 writer thread.
How can i apply the Sychronized(), lock(), and SyncRoot in my context?
I am quite new to C#, so I may not know certain things that u assumed that I should know. Can any1 provide me with a more detailed example, or perhaps point me to a more elaborative resource? thanks a bunch.
|
|
|
|
|
viperxp wrote:
is syncList an identical copy of theList, or just another reference to theList?
It is wrapper around theList, which internally contains a reference to it.
viperxp wrote:
How can i apply the Sychronized(), lock(), and SyncRoot in my context?
With Synchronized() you don't have to do anything but ensure that you do all of your reading and writing with syncList.
From the documentation on the "lock statement" (since I couldn't think of the correct wording, but slightly modified):The lock keyword marks a block [of code] as a critical section by obtaining the mutual-exclusion lock for a given object, executing [the code], and then releasing the lock. You use it by passing in a reference to an object which will serve as the 'key' to entering into the lock.
In this case, the 'key' to the ArrayList is returned by the SyncRoot property.
HTH,
James
"I despise the city and much prefer being where a traffic jam means a line-up at McDonald's"
Me when telling a friend why I wouldn't want to live with him
|
|
|
|
|
First of all,
Thanks for prompt reply.
James T. Johnson wrote:
With Synchronized() you don't have to do anything but ensure that you do all of your reading and writing with syncList.
Are u saying that whenever I need to access (be it read / write) theList, I just get the enclose the code block in a lock(syncList.SyncRoot), no matter where the read / write operation lies... in my case, they are in different classes.
From what u wrote, it seems that i dont have to do any checks, i.e. is there any other threads accessing tthe list or not etc b4 commencing my "I/O" operations... is my interpretation correct?
can i put it in this way....
syncList.SyncRoot provides a "safe" reference to theList. whenever any code within lock(syncList.SyncRoot) is running, all other code accessing theList - most probably thru the syncList.SyncRoot reference, regardless of whether it's in a lock() block or not, will have to wait till the "active" lock() block completes?
how about deadlock and "starvation" problems...? e.g. when a thread terminated prematurely, will the lock be released? if not, wut can i do prevent this prob?
Thanks again, yur replies helps a great deal
|
|
|
|
|
By default all forms are inherited from System.Windows.Forms.Form. The wizard generates code like this:
public class Form1 : System.Windows.Forms.Form
That is nice, but I would like to interject a class with common behaviors for all my forms. Like this;
class BaseForms : System.Windows.Forms.Form
and then inherit from there like so;
public class Form1 : System.Windows.Forms.Form
The problem is I get the message below and I am not sure why.
C:\NET_Phil\FormsInherit\Form1.cs(21): Inconsistent accessibility: base class 'FormsInherit.BaseForms' is less accessible than class 'FormsInherit.Form1'
All the wizard generated source is below. I have only modified the lines discussed.
Thanks for your time.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace FormsInherit
{
class BaseForms : System.Windows.Forms.Form
{
public BaseForms()
{
Console.WriteLine("BaseForms");
}
public int iValueAll;
}
///
/// Summary description for Form1.
///
public class Form1 : BaseForms
{
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
}
}
}
|
|
|
|
|
Make BaseForm public
<a TITLE="See my user info" href=http:
|
|
|
|
|
Yes, I feel dumb, but thank you.
|
|
|
|
|
I don't have much experience with web services beyond basicly reviewing the technology and trying a few demos. I am thinking of using a set of web services in my issue tracking project but I am a little concerned with performance. It is very important to me for the final product to be very responsive, so I don't want to use anything that compromises that.
Assuming the web service were running on a server (Win2k, 1gb, scsi, SQL local) in the same office as the user, exposed through a Windows service, basically just "Get a record", "Save a record", could I expect sub-second response times for total round trips (ie. App requests record to Record received.) I still need some of that second to deal with processing the request by the user and displaying the results.
I know nobody can promise performance, I will eventually have to test it, but I would like to hear from pepole more familiar with me to get a better understanding of what to expect.
One last question, what are the best resources for learning the best way to program web services?
Thanks in advance.
Matt Gullett
|
|
|
|
|
Have you considered using .net remoting, since your application seem to run in a intranet environment. I believe remoting gives better performance than webservices, as it can use binary formatters.
Cheers,
Kannan
|
|
|
|
|
Thanks for the feedback, but no I have not seriously considered .net remoting for several reasons.
1) Not all parts of this application will be written in .NET (I think?)
2) I would like this system to be useable outside the intranet also (if reasonably possible)
3) .NET remoting may be problematic due to the dynamic nature of the structure of issues (See my article series 'The life of a project..." for a better understanding.
4) I want to produce a system that can self-document the changing nature of itself which I don't see how remoting can do.
Anyway, thanks, it's not a bad idea, but I just don't see how I could use it for this project. If you think I could still use it, please let me know.
Thanks,
Matt Gullett
|
|
|
|
|
Sorry Matt, I didn't know you had a article series behind your question
These things happen when you start visiting the lounge and the forums directly without checking out cp main page
I'm reading the first one, thank you for a great looking article
Regards,
Kannan
|
|
|
|
|
It really depends on many issues such as bandwitdh, latency, what kind of data you will be passing and what size. If you are planning on flipping through records (navigating one at a time) via datasets and don't happen to have T1 lines, it can get slow.
You mention in another post that you may also be using this over the Internet. I was going to use Web Services to communicate between my application and the SQL Server over the Internet passing DataSets. The internet connection is a SDSL line on one end at 384K/384K and a cable modem at the other at 1500K/128K. The web services were using Windows security.
Sometimes the first connection to the server via web services would take sometimes 2-3 seconds while a couple of times it took over 10 seconds.
Connecting to a running Sql Server directly in the code was sub-second and the same goes for fetching records.
I also had web services for posting images automatically that would range from a few K to 90K per imagine on matching DSL connections at 384K/384K. A seperate Web Service call was made for each imagine posted as a DIME attachment. It was tremendiously slow by doing it per image.
The server machine is very old technology and may be the reason for the slow response. It is only a PII450 with 256 megs of RAM.
Rocky Moore <><
|
|
|
|
|
Thanks for the feedback.
I have been researching the topic and have found allot of usefull information and performance statistics. You are correct in saying that it depends. What I get from this is that if I decide to use web services, I need to design them for actual usage behaviours and optimize them accordingly.
Thanks,
Matt Gullett
|
|
|
|
|
Hi!
Do you know how to do that?
I have a lot of objects. I want to serialize them, but some has not serializable attributes...
I want to create clones from the original objects dynamically.
How to solve this?
AgyklonN
|
|
|
|
|
Hi,
I wrote a simple C# service that uses remoting. It installs just fine, but for some reason when I try to start the service, I get the error message "Service 'SharpPrivacy OpenPGP Service' on 'local machine' could not be started. Error: 193 (0xc1)" (message was translated from german to english by me. It might not be exactly the same in english WinXP). I didn't find anything on the web about that error. Does someone know what might be the problem?
The service is generally the normal Service template, I only changed the function onstart:
<br />
protected override void OnStart(string[] args) {<br />
HttpChannel myChannel = new HttpChannel(4433);<br />
<br />
ChannelServices.RegisterChannel(myChannel);<br />
RemotingConfiguration.RegisterWellKnownServiceType(typeof(SharpPrivacy.SharpPrivacySrv.SharpPrivacy), "SharpPrivacy", WellKnownObjectMode.Singleton);<br />
}<br />
TIA,
Daniel
PS: If interested in SharpPrivacy (an OpenPGP implementation in c#), read my article[^] about it.
|
|
|
|
|
I had to go to Windows Components and Internet Information Services (IIS).
You are failing some kind of security check. If this works for you as it did me, you can then re-install IIS.
Good luck.
|
|
|
|
|
I don't quite understand. Do you know what kind of security check causes the error? And how would reinstalling IIS help?
Greets,
Daniel
|
|
|
|
|
I do not understand either. I am just telling you what we had to do.
We found this by comparing where the software worked and where it did not.
Sorry, it is a strange .NET world.
|
|
|
|
|
Hi && thanks for your answer. I set the installer to log on as the local system acount and as I am administrator, it should work, shouldn't it?
Anyway in the meantime I had a look into the event log, and there I found the corresponding error message: "SharpPrivacySrv is not a valid Win32 application".
I found a few references to that error on google (here[^]) but not a single solution to the problem.
Any ideas left?
Greets,
Daniel
|
|
|
|