|
thanx , i'll give it a try!
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hello Friends,
Season greetings.
I am working in a C# (VS2005) windows application. In that I need to draw Contour chart.
I tried with different chart components, but they are following different patterns..not providing the expected result. I expect that, the component should produce the graph as same as the MS Excel draws contour chart for a speciific data.
Can anybody tell me which component I have to use for this type chart.
Thanks in Advance
Raja
|
|
|
|
|
Maybe this google search[^] can help you out. The first few components look interesting...
Some people have a memory and an attention span, you should try them out one day. - Jeremy Falcon
|
|
|
|
|
hi all,
i have a question that i have been thinking of for a while.
when i need to have an application that look like, for example, out look with a side panel and a cente panel. When clicking on a button on the side panel the center panel changes it components.
I usually use "UserControls" for this kind of application. And i assign the userCOntrols to the middle panels. It works fine with no problems.
But i have been thinking if i can assign form like that. Not a form that opens as a new window separate from the mother window. but a form that opens inside the mother form.
if it is possible please brief me.
|
|
|
|
|
|
Hello experts,
I'm having a hard time understanding how locking occurs.
How does using the lock statement, or any other synchronization mechanism for that matter, solves the following issue:
Lets say there are 2 threads running the following code:
bool busy = false;
void foo()
{
if (!busy)
{
busy = true;
busy = false;
}
} if the 1st thread enters the function it will evaluate the !busy statement and succeed in entering the conditioned code block.
However, if it didn't yet perform the busy = true; statement, there's a chance that the 2nd thread, if started at that moment, could also evaluate the !busy statement, thus also entering the conditioned block.
So now both threads are running the critical section.
Any ideas regarding how .NET implements locking? Obviously the above code is not the way...
|
|
|
|
|
static object locker = new object();
static void Function()
{
lock (locker)
{
}
}
Tarakeshwar Reddy
MCP, CCIE Q(R&S)
|
|
|
|
|
Yeah well... I know that much...
I meant to ask what happens when we use the lock statement...?
I know that the compiler translate it to somthing like the following:
try
{
Monitor.Enter();
}
finally
{
Monitor.Exit();
} So how is the Monitor class implemented?
|
|
|
|
|
Ah hmm. You could read these articles, they could probably answer your questions. Link1[^], Link 2[^], Link 3[^]
Tarakeshwar Reddy
MCP, CCIE Q(R&S)
|
|
|
|
|
Hmm... Those all discuss how to use locking mechanisms, but again... That's not what I'm looking for...
I would like to know how is the Monitor.Enter() implemented.
Let's say that foo() (in my original post) is Enter() .
How is it guaranteed that two threads would never evaluate the lock Monitor aquired at the same time, and enter the actual lock aquiring statement at the same time?
|
|
|
|
|
From this[^] excellent blogpost by Joe Duffy :-
As you may have guessed, Monitor actually uses Windows events underneath it all. Each CLR thread has a manual-reset event, allocated when it is created (or lazily when the thread first wanders into managed code). When a Wait is issued, this per-thread event is stuck on the tail of a linked list associated with the target object’s sync block. We can use a single event per thread since a thread can only ever be waiting for a single object at a given time. (You can’t do a WAIT_ANY or WAIT_ALL on monitors.) The thread then releases the lock on the object (accounting for any recursion), waits on this event, and then reacquires the lock on the object (again, accounting for any recursion). When a Pulse is issued, the head of the object’s linked list of waiters is popped off and its associated event is signaled. Similarly, PulseAll clears the entire linked list and signals all of the events. Notice I said that Pulse operates on the head of the list: we use a strict FIFO ordering (as of 2.0)....
|
|
|
|
|
Cool
|
|
|
|
|
Calls to System.Threading.Monitor.Enter() and System.Monitor.Exit() marks the critical section of the code. Like,
System.Threading.Monitor.Enter(this);
System.Threading.Monitor.Exit(this);
(System.Threading.Monitor is one of the .NET base class).
Now, what ever thread make call to the Monitor.Enter() first, this call will ensure that the first thread will finishes first (which is marked by calling the Monitor.Exit() method), before any other thread gain access to the code/method.
________________________________
Success is not something to wait for, its something to work for.
|
|
|
|
|
In the end it boils down to using a processor instruction that sets a value and gets the previous value as an atomic operation. In pseudo code this would be:
static int status = 0;
if (status == 0) {
int prevStatus = status.SetNewAndGetPrevious(1);
if (prevStatus == 0) {
status = 0;
} else {
}
}
This is used somewhere deep in the code that creates monitors.
---
It's amazing to see how much work some people will go through just to avoid a little bit of work.
|
|
|
|
|
i have created a list view and have ways to put in information, edit it, and delete one at a time. But i cannot get it to delete more than one at a time. My code is:
if (listView1.SelectedItems.Count > 1)
{
int SelectedItemCount = listView1.SelectedItems.Count;
int usableSelectedItemCount = SelectedItemCount - 1;
if (MessageBox.Show("Are you sure you want to delete these " + SelectedItemCount + " items?", "Confirm Delete",
MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, 0) == DialogResult.Yes)
{
for (int Removed = 0; Removed < usableSelectedItemCount; Removed++)
{
listView1.Items.Remove(listView1.SelectedItems[Removed]);
}
}
else if (listView1.SelectedItems.Count == 1)
{
if (MessageBox.Show("Are you sure you want to delete?", "Confirm Delete", MessageBoxButtons.YesNo,
MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, 0) == DialogResult.Yes)
{
listView1.Items.Remove(listView1.SelectedItems[0]);
}
}
Did i mess up by approaching the for loop incorrectly? What can i do to fix it?
Thanks for the help.
(and sorry about the long code)
|
|
|
|
|
This code might help you...
if (listView1.SelectedItems.Count > 0)
{
int SelectedItemCount = listView1.SelectedItems.Count;
int usableSelectedItemCount = SelectedItemCount - 1;
if (MessageBox.Show("Are you sure you want to delete these "
+ SelectedItemCount + " items?",
"Confirm Delete", MessageBoxButtons.YesNo,
MessageBoxIcon.Warning,
MessageBoxDefaultButton.Button2, 0) == DialogResult.Yes)
{
foreach (ListViewItem item in listView1.SelectedItems)
{
listView1.Items.Remove(item);
}
}
else if (listView1.SelectedItems.Count == 1)
{
if (MessageBox.Show("Are you sure you want to delete?",
"Confirm Delete", MessageBoxButtons.YesNo,
MessageBoxIcon.Warning,
MessageBoxDefaultButton.Button2, 0) == DialogResult.Yes)
{
}
}
}
Look at the if condition for greater than one.
Jayant D. Kulkarni
Brainbench Certified Software Engineer in C#, ASP.NET, .NET Framework and ADO.NET
|
|
|
|
|
How can I get a reference of the calling Assembly at Runtime?
I've an assembly (RestrictedAssembly) and I want to ristrict access to it means no user who fullfills my criteria (in my case not having my desired public key token for assembly) can instantiate any type from my assembly.
For better understanding, this is what I am trying to do.
I've generated a public/private keypair file for myself, then I use it to sign all those assemblies which I want to allow Access to my RestrictedAssembly. On Runtime before instantiating any type from RestrictedAssembly, in constructor I am asking the caller to provide a Type object from which he's initiating a call to constructor. For example.
public RestrictedType1(Type o) {
Type t = this.GetType ();
byte [] t1Token = o.Assembly.GetName().GetPublicKeyToken();
byte [] t2Token = t.Assembly.GetName().GetPublicKeyToken();
AccessNotAllowedEx ex = new AccessNotAllowedEx("Not Allowed");
if(t1Token != null && t2Token != null) {
if(t1Token.Length == t2Token.Length) {
for(int i = 0; i< t1Token.Length; i++) {
if (t1Token[i] == t2Token[i])
continue;
else
throw ex;
}
ex = null;
} else
throw ex;
} else
throw ex;
}
I am checking, if the public key tokens for both the calling and called assemblies are identical and if they are, then I am allowing the caller to instantiate my RestrictedType other wise I raise an exception.
Now the problem with this approach is that, suppose I've an Assembly CallerOfRestrictedAssembly and I've signed it with my public/private key pair. Now from CallerOfRestrictedAssembly it is valid to do the following. Since both assemblies have same public key token.
RestrictedType1 res = new RestrictedType1(this.GetType);
However, suppose if some one initiate a call to RestrictedType1 constructor
RestrictedType1 res = new RestrictedType1(typeof(TypeFromCallerOfRestrictedAssembly));
This will cheat the constructor. Thus, I don't want caller to Pass Type argument into Constructor. and depend on it. What I am looking for is to get a reference of Calling Assembly into my RestrictedAssembly at Runtime?
I'll apreciate if some can help with this or any other approach to achieve this level of code restriction? Thanks.
SMK
|
|
|
|
|
Please don't cross post.
---
It's amazing to see how much work some people will go through just to avoid a little bit of work.
|
|
|
|
|
Syed Muhammad Kamran wrote: How can I get a reference of the calling Assembly at Runtime?
You mean something like Assembly.GetCallingAssembly() method?? Don't forget to reference the System.Reflection namespace.
PS.
Even this got ways to be cracked with.
Regards
|
|
|
|
|
There are ways to even crack this.....
You mean like this??
Assembly asm = Assembly.GetAssembly ( Type ( MyRestrictedAssembly ) );
byte[] b = asm.GetName ().GetPublicKey ();
this.GetType ().Assembly.GetName ().SetPublicKey ( b );
TypeFromRestrictedAssembly temp = new TypeFromRestrictedAssembly ( this.GetType ().Assembly );
SMK
|
|
|
|
|
Well, not exactly. You can crack it using MSIL dissassembler. Just disassemble the code, copy/paste it, or remove the few lines that check for the calling assembly and save the dll files. Yes, it isn't that easy, but it's still doable. If you are not expecting hardcore persistant crackers to hut your application, it would be a nice way of protecting someone from using your code by referencing. Another way to protect your program from being used by reflection also could be the Dotfuscator. It's a small freeware tool to obfuscate your cde against disassembling. Still crackable, but a bit harder.
Regards
|
|
|
|
|
using TcpClient, i have made a client Server chat application. Server is running on another computer. in Client side i use the server IP address and PORT number to connect. If the server is running Any Computer the Client should automatically find the server Ip address how it is possible?
//
now i am using like this
Client Side
TcpClient tcp=new TcpClient();
tcp.Connect("192.0.0.3",8888);
//
Sanjit.rajbanshi@wlinktech.com
|
|
|
|
|
You would need to broadcast to all the machines on the network and the machine running the server could send back a reply and you can connect to it.
It is similar to how your DHCP works.
Tarakeshwar Reddy
MCP, CCIE Q(R&S)
|
|
|
|
|
I'm setting up an authentication system for access to a server through a remoting layer.
Using custom channel sinks to do this doesn't seem to be a problem.
The problem is that if someone is authenticated as, say "bob" within the remoting layer, then the remote object also needs to know that the method was called by "bob".
Is there any way to pass extra information like this from the remoting layer to the application layer without it being a parameter of the remote method called? Some sort of shared remoting context object, or the like?
|
|
|
|
|