|
hemant saliya wrote: so what can i do .. for that..
Steps
1. Learn the basics of C#
2. Learn the basics of requirements gathering
3. Learn the basics of design
4. Learn the basics of "web" servers including various protocol types.
5. Learn how to program 4 in C#.
6. Use 2 to create your requirements
7. Use 3 and 6 to design your system.
8. Use 1, 4 and 7 to create your system.
9. Unit test your system.
|
|
|
|
|
I m using DataGridView.
It has a checkbox column, i want to check - uncheck this CheckBox control..
In asp.net FindControls() is used to get control, is there any methon like FindControls() for Windows ?
|
|
|
|
|
To set the value of a CheckBoxCell you need to cast it specifically like this:
(dataRow.Cells["your cell index"] as DataGridViewCheckBoxCell).Value = true;
This presumes dataRow is your current datagridview row.
Hope this helps
...and I have extensive experience writing computer code, including OIC, BTW, BRB, IMHO, LMAO, ROFL, TTYL.....
|
|
|
|
|
Hi, Currently I have a server-client application which works fine. I only want the server to serve for a predefined number of clients. Say, up to 20 clients. If I adjust the below behavior it should be okay.
But since each client subscribe to server with a client number, e.g. client22 or client29 which are greater than number 20 will connect to server when the total number of concurrent sessions or instances are lover than 20. And so, if these two clients connect and allocate two connections before, Any two clients with numbers upto 20 will not be able to connect afterwards. Any solution for this? Thanks
in short: I want only 20 clients, client1,client2.....client20 can connect but client21, client22 and so on can't connect
ServiceThrottlingBehavior behaviour = new ServiceThrottlingBehavior();<br />
behaviour.MaxConcurrentSessions = 20;<br />
behaviour.MaxConcurrentInstances = 20;
|
|
|
|
|
What do "client number"s and ServiceThrottling settings have to do with each other?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Isn't the servicethrottling onyl way of limiting numbers of clients that can connect to server by controlling service instances and concurrency? So I want to limit max connections to a specific number of clients
|
|
|
|
|
Have you tried using sessions and limiting the number of sessions?
Besides the configuration you've shown, make sure sessions are required and concurrency/instance context modes are set on the service contract:
[ServiceContract(SessionMode = SessionMode.Required)]
public interface IService1
{
}
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.PerSession)]
public class Service1 : IService1
{
}
Sessions, Instancing, and Concurrency[^]
Discover Mighty Instance Management Techniques For Developing WCF Apps[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello,
I want to do the integrity check zip files, I would use 7zip library with the command 't' using this code:
try
{
Process rr = Process.Start(@"..\Release\7Z\7z.exe ", @" t ..\Release\.zip > .\1.test");
rr.WaitForExit();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
Order fontionne well on the lin command (CMD), except with the code below, it doesn't generate the file 1.test.
Thank you verry mutch.
|
|
|
|
|
abbd wrote: it doesn't generate the file 1.test.
If 7z had encountered an error, it would have written that to the file ".\1.test". There's also a space at the end of your path to the 7z-executable, that shouldn't be there. Does it print anything on the console if you run it?
Bastard Programmer from Hell
|
|
|
|
|
Hi,
I need to enumerate directories/shares (and their permissions), so far, I found two appraches:
OPTION 1: WMI[^]
- advantage: You can query remote computers if you have the permission to...[^]
- limitation is that: (a) Don't give local path, (b) I need "Permission", noth NTFS+Share, which WMI object don't provide.
This said, I did came across Win32_SecuritySettingOfObject[^], but don't know how to use it. And still trying Win32_SecuritySetting (But samples are so hard to decipher, for example, ControlFlags = 32772. This means absolutely nothing to me) [^] - how to get list of users/groups assigned to access to share folder?[^]
After more digging around, seems like answer (last challenge) is to call Win32_Share.GetAccessMask from C#[^] --- HELP! Sample from here don't work...[^]
OPTION 2: DllImport win32 API - WNetGetUniversalName and NetShareEnum [^]
- advantage: gives local path of identified shares and also able to scan both local/remote shares
- limitation: Option 2 actually gives local path, but nothing on directory/share "Permission".
note SHARE_INFO_2 has an "Permission (int)" field, but after examining further doesn't appear this is what I'm looking for. Also examined new System.IO.DirectoryInfo(share.Path) --- nothing useful from there.
Any suggestion guys? I need permissions - both NTFS+Share access permissions[^]... (Basically same as right click folder, select "Properties", look under "Security" tab and also "Sharing\Permissions")
Thanks!
OPTION 1 - sample code:
<br />
<br />
public static IList<string> EnumerateLocalShares(ShareCheckingMode Mode)<br />
{<br />
IList<string> Shares = new List<string>();<br />
SelectQuery query = null;<br />
ManagementObjectSearcher searcher = null;<br />
<br />
switch (Mode)<br />
{<br />
case ShareCheckingMode.Win32_LogicalShareAccess:<br />
query = new SelectQuery("SELECT * FROM Win32_LogicalShareAccess");<br />
break;<br />
case ShareCheckingMode.Win32_LogicalShareAuditing:<br />
query = new SelectQuery("SELECT * FROM Win32_LogicalShareAuditing");<br />
break;<br />
case ShareCheckingMode.Win32_LogicalShareSecuritySetting:<br />
query = new SelectQuery("SELECT * FROM Win32_LogicalShareSecuritySetting");<br />
break;<br />
}<br />
<br />
searcher = new ManagementObjectSearcher(query);<br />
foreach (ManagementBaseObject share in searcher.Get())<br />
{<br />
Console.WriteLine("Share: " + share.ToString());<br />
foreach (PropertyData prop in share.Properties)<br />
{<br />
Console.WriteLine("Property - " + prop.Name + ": " + prop.Value);<br />
}<br />
foreach (PropertyData prop in share.SystemProperties)<br />
{<br />
Console.WriteLine("SystemProperty - " + prop.Name + ": " + prop.Value);<br />
}<br />
foreach (QualifierData Qualifier in share.Qualifiers)<br />
{<br />
Console.WriteLine("Qualifier - " + Qualifier.Name + ": " + Qualifier.Value);<br />
}<br />
Console.WriteLine();<br />
Console.WriteLine();<br />
}<br />
<br />
return Shares;<br />
}<br />
For NTFS folder permission (Not "Share" permission) [^]
<br />
public static FileSystemAccessRule GetDirectoryPermissions(string user, string domainName, string folderPath)<br />
{<br />
if (!Directory.Exists(folderPath))<br />
{<br />
return (null);<br />
}<br />
<br />
string identityReference = ((domainName + @"\" + user) as string).ToLower();<br />
DirectorySecurity dirSecurity = Directory.GetAccessControl(folderPath, AccessControlSections.All);<br />
foreach (FileSystemAccessRule fsRule in dirSecurity.GetAccessRules(true, true, typeof(System.Security.Principal.NTAccount)))<br />
{<br />
if (fsRule.IdentityReference.Value.ToLower() == identityReference)<br />
{<br />
return (fsRule);<br />
}<br />
}<br />
return (null);<br />
}<br />
dev
modified on Wednesday, May 18, 2011 6:36 AM
|
|
|
|
|
I think I found how to enumerate share permissions. However, I can't interpret AccessMask = 1179817, MSDN didn't help (none of listed constants matches 1179817)[^]
I stumbled across this[^]
<br />
# Constants<br />
$SHARE_READ = 1179817<br />
$SHARE_CHANGE = 1245462<br />
$SHARE_FULL = 2032127<br />
$SHARE_NONE = 1<br />
Compared against actually setting, "1179817" is indeed READ.
<br />
ManagementObject sharedFolder = WMIUtil.GetSharedFolderObject("TestShare$");<br />
ManagementBaseObject securityDescriptorObject = sharedFolder.InvokeMethod("GetSecurityDescriptor", null, null);<br />
ManagementBaseObject securityDescriptor = securityDescriptorObject.Properties["Descriptor"].Value as ManagementBaseObject;<br />
int existingAcessControlEntriesCount = 0;<br />
ManagementBaseObject[] accessControlList = securityDescriptor.Properties["DACL"].Value as ManagementBaseObject[];<br />
existingAcessControlEntriesCount = accessControlList.Length;<br />
Array.Resize(ref accessControlList, accessControlList.Length + 1);<br />
foreach (ManagementBaseObject o in accessControlList)<br />
{<br />
WMIUtil.DisplayProperties(o);<br />
}<br />
<br />
Now ...
<br />
public static void DisplayProperties(ManagementBaseObject o)<br />
{<br />
if (o == null)<br />
{<br />
return;<br />
}<br />
<br />
Console.WriteLine();<br />
Console.WriteLine("Object: " + o);<br />
<br />
foreach (PropertyData prop in o.Properties)<br />
{<br />
if (prop.Value is ManagementBaseObject)<br />
{<br />
ManagementBaseObject childObj = (ManagementBaseObject)prop.Value;<br />
DisplayProperties(childObj);<br />
}<br />
else<br />
{<br />
Console.WriteLine("Property - " + prop.Name + ": " + prop.Value);<br />
}<br />
}<br />
<br />
foreach (PropertyData prop in o.SystemProperties)<br />
{<br />
Console.WriteLine("SystemProperty - " + prop.Name + ": " + prop.Value);<br />
}<br />
<br />
foreach (QualifierData Qualifier in o.Qualifiers)<br />
{<br />
Console.WriteLine("Qualifier - " + Qualifier.Name + ": " + Qualifier.Value);<br />
}<br />
<br />
return;<br />
}<br />
dev
modified on Thursday, May 19, 2011 3:30 AM
|
|
|
|
|
Is there a chance for a Dispose() method to be called by GC if class is not inhereted from IDisposable?
class My
{
public void Dispose()
{
}
}
I provided that method to immediatly release some memory resources for the class.
I wonder if it is prohibited to name some functions after well known methods as Dispose?
I experience the following problem Windows service stable APPCRASH in clr.dll after 3.5 to 4.0 .NET platform change[^] which occur in windows service application only.
Чесноков
|
|
|
|
|
The runtime won't call it, but will it be confusing to future people looking at the code?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
The GC calls Dispose methods only on IDisposable objects. So, in your case GC will not call the Dispose method. Although it is not illegal to use the name 'Dispose' for your cleanup methods, other developers who work with your code may get confused.
EDIT:
I meant to say the that the GC calls the finalizer which in turn is supposed to call Dispose method. The GC does NOT call Dispose method directly even if the class implements IDisposable interface.
However, in a using code block, the C# compiler checks if the class implements IDisposable interface when compiling the code into a try...finally... block and calls its Dispose method in the finally block.
modified on Wednesday, May 18, 2011 9:44 AM
|
|
|
|
|
As it stands, Dispose is just a method name. The trick with IDisposable objects is that the interface is well known, so it can be accessed using (effectively):
IDisposable = thisClass as IDisposable;
if (thisClass != null)
thisClass.Dispose();
|
|
|
|
|
Shouldn't the code be something like this?
IDisposable i = thisClass as IDisposable;
if (i != null) {
i.Dispose();
}
|
|
|
|
|
It should. That's what I get for typing replies on a phone.
|
|
|
|
|
Never mind, as long as it conveys the idea. But beginners might have a problem though.
|
|
|
|
|
Maybe, if it's called from the finalizer.
But I would implement the IDisposable interface, it's free.
|
|
|
|
|
Hello Experts,
I want to open autocad file in my application so please suggest me what component or library is the best for this usage.
Thanks
If you can think then I Can.
|
|
|
|
|
Google[^]!
The best things in life are not things.
|
|
|
|
|
This may help[^]
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
I'm looking to add threading support to an application I'm working on, and am looking for advice on how to accomplish this.
I have a collection of objects which are updated through a foreach loop. Instead, I'd like to dedicate this to a series of threads, where each object is moved in for processing as the thread becomes available.
I've come up with 2 approached on how to do this.
Method 1: Using a WaitHandle
Give each thread an AutoResetEvent and rely on the WaitHandle.WaitAny() method to identify when a thread is finished so a new one can be created.
Link: MSDN[^]
Pseudocode:
void QueueThreads(IEnumerable myCollection, uint maxThreads)
{
uint usedThreads = 0;
AutoResetEvent[] autoEvents = new AutoResetEvent[Math.Min(maxThreads, myCollection.Count)];
foreach (T myObject in myCollection)
{
if (usedThreads < maxThreads)
{
autoEvents[usedThreads] = new AutoResetEvent(false);
usedThreads++;
}
else
{
uint freeThreadID = WaitHandle.WaitAny(autoEvents);
usedThreads--;
usedThreads++;
}
}
WaitHandle.WaitAll(autoEvents);
}
void DoWork(myObject, AutoResetEvent are)
{
are.Set()
}
Method 2: Sharing the enumerator across threads
Give each thread access to the enumerator used to iterate over the collection. Each thread stays alive until all items in the collection have been exhausted.
Pseudocode:
void QueueThreads(IEnumerable myCollection, uint maxThreads)
{
uint usedThreads = 0;
IEnumerator myCollectionEnum = myCollection.GetEnumerator();
for (uint i = 0; i <= Min(myCollection.Count,maxThreads); i++)
{
}
myCollectionEnum.Reset();
}
void DoWork(IEnumerator myColEn)
{
do
{
T myObject;
lock (myColEn)
{
if (myColEn.MoveNext())
{
myObject = myColEn.Current
}
else
{
break;
}
}
}
}
My experience with threading has been only experimental, so I'm hoping the CP threading vets can provide input on which approach is best, or if there's a third option worth considering.
As for starting a thread, I’ve seen a few different methods for doing this (ThreadPool.QueueUserWorkItem() , new Thread(new ThreadStart()) , BackgroundWorker ) , but don’t really know when to use which one.
Note that file/database IO would need to be synchronized between the threads, but aside from that, there shouldn't be any issued with shared resources as each object maintains its own state.
Also, I am restricted to using .Net 2.0.
modified on Thursday, September 15, 2011 2:37 PM
|
|
|
|
|
The question to ask would be why you are trying to use multiple threads, what are you expecting to gain from it? If it is increased performance you may not get what you are looking for since the bottle neck would most likely be at the file IO or database level.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Essentially, this process would be to collect data from a list of networked machines. Most of the latency comes from locating the machine and then establishing a connection. The threading is so I could continue to process other machined while one is waiting to connect.
|
|
|
|