|
whats the issue you are facing ?
|
|
|
|
|
hello, my program use socket class to find ip packet info.
My project is related with lan monitoring. Is there any way to use
this class without using manifest file when application install in admin account.
i don't want to use manifest for "requireAdministrator" bcoz app
didn't work when i added it in window startup prgram.
tell me is this possible
thank u for any help.
|
|
|
|
|
Monitoring network traffic (i.e.: using WinPCap) always requires administrivate permissions. I can't think of a situation where it wouldn't.
Put the admin manifest in your project. If it's in the users Startup folder, at worst, it'll ask for permission to run when they login.
|
|
|
|
|
i also think that.....
but i m not confirm.
thank you
|
|
|
|
|
If the WinPCap service is installed and the service is set to SERVICE_AUTO_START then the application will not require administrator credentials. However this is probably irrelevant if the OP is simply putting the network device in promiscuous mode.
|
|
|
|
|
Hi there,
I´m trying to understand how Methods with Predicate and Conditions work; it´s a little confusing for me.
For example, we have a 10-positions array of bytes, such as
public byte[] Client_ID_List { get; private set; }
, it´s initialized by:
Client_ID_List = new byte[8];
After a while, I want to find the first position in this array that has '0' value.
I have seen that First method returns the first element that satisfies a condition, but I don´t really understand how Predicate argument works.
Any help or simple example will be very useful.
Or maybe any other idea to solve this issue.
Kind Regards,
D.
|
|
|
|
|
A predicate is just a method that returns a boolean value. Thus to use a predicate in a .First query, you can either use a Lambda expression
byte FirstZeroByte()
{
return ClientIdList.First((b) => b == 0);
}
or pass a method to the query that returns a boolean
bool IsZeroByte(byte byteToCheck)
{
if (byteToCheck == 0)
return true;
return false;
}
byte FirstZeroByte()
{
return ClientIdList.First(IsZeroByte);
}
Hope this helps
Live for today. Plan for tomorrow. Party tonight!
|
|
|
|
|
Hi guys, I'm currently working on a ship management system. The problem lies in the main bridge between the ships and the server. When there is more than 700 ships, the bridge doesn't send the message to the server in FIFO order, causing the display in the application to appear as jumping back and forth.
After a bit of debugging (and searching of course), I found that the root of the problem is within lock(){} which process data within a list just before sending it to server. There are 10 Threads managing this List, All of them does the same job (The previous version which use just 1 list doesn't have this error but it's very slow and it has a huge memory usage). This is because lock release thread according priority, causing the latest ship data to be sent before the older ship data. I do realize that .net doesn't have any FIFO Lock and I do realize the existence of ConcurrentQueue<t>[^] and other thread safe collection, but this application must run on .net 2.0 (dunno why). So is there any solution to this problem? (It's not necessarily a FIFO Collection , a FIFO Lock will do)
So far, I tried replacing lock with this class:
using System.Threading;
public sealed class QueuedLock
{
private object innerLock;
private volatile int ticketsCount = 0;
private volatile int ticketToRide = 1;
public QueuedLock()
{
innerLock = new Object();
}
public void Enter()
{
int myTicket = Interlocked.Increment(ref ticketsCount);
Monitor.Enter(innerLock);
while (true)
{
if (myTicket == ticketToRide)
{
return;
}
else
{
Monitor.Wait(innerLock);
}
}
}
public void Exit()
{
Interlocked.Increment(ref ticketToRide);
Monitor.PulseAll(innerLock);
Monitor.Exit(innerLock);
}
}
But it doesn't help. In fact, it increases the error percentage from 20% (Simulated with a generator that generate 100.000 ship data) to 23% [Edit:Miscalculation on error count ]
So, does anyone here have an idea on how to solve this? Any ideas will be greatly appreciated.
Excuse me for my improper grammar and typos.
It's because English is my primary language, not my first language.
My first languages are C# and Java.
VB, ASP, JS, PHP and SQL are my second language.
Indonesian came as my third language.
My fourth language? I'm still creating it, I'll let you know when it's done!
modified on Thursday, August 25, 2011 4:56 AM
|
|
|
|
|
|
Um,, I think I use wrong title for my thread. Fixed now.
Nevertheless, I'll try using Queue as described here[^].
[Edit]
Error percentage:6% [Edit2:Miscalculation ]
Well, at least it's better than my solution. Yosh, I'm making progress, thanks
[/edit]
Excuse me for my improper grammar and typos.
It's because English is my primary language, not my first language.
My first languages are C# and Java.
VB, ASP, JS, PHP and SQL are my second language.
Indonesian came as my third language.
My fourth language? I'm still creating it, I'll let you know when it's done!
|
|
|
|
|
It does show you how to lock the queue in the middle of the page.
|
|
|
|
|
Well, yeah. But what I'm looking for is to make a FIFO Lock in .net 2.0. Anyway, thanks, guess I'll experiment a bit more
Excuse me for my improper grammar and typos.
It's because English is my primary language, not my first language.
My first languages are C# and Java.
VB, ASP, JS, PHP and SQL are my second language.
Indonesian came as my third language.
My fourth language? I'm still creating it, I'll let you know when it's done!
|
|
|
|
|
Now you have confused me! You are trying to re-invent the wheel?
QUEUE is FIFO
Look at the section in the link I sent you, it discusses thread safety and locks via a Synchronize wrapper....
Eveything is there for you. Good luck
|
|
|
|
|
DaveAuld wrote: You are trying to re-invent the wheel?
Yes, I got that class from this page[^]. It says that there is no FIFO locks in .net and I have to create my own.
Excuse me for my improper grammar and typos.
It's because English is my primary language, not my first language.
My first languages are C# and Java.
VB, ASP, JS, PHP and SQL are my second language.
Indonesian came as my third language.
My fourth language? I'm still creating it, I'll let you know when it's done!
|
|
|
|
|
Dave is right, a Queue is what you seem to need here. And don't think of it as a QueuedLock, look for a LockedQueue, i.e. a queue that uses a single lock to make it thread-safe. That is bound to keep your data in FIFO order. You can easily build a LockedQueue yourself, or just google the term to find several examples.
|
|
|
|
|
How to register .ocx file with (regsvr32) from code in C# ?
|
|
|
|
|
System.Diagnostics.Process.Start("regsvr32 " + ocxfile_path);
|
|
|
|
|
I did it but says: The system cannot find the file specified
|
|
|
|
|
Use a fully qualified path. Something like this:
string ocxPath = Path.Combine(Application.StartupPath, "myocxfile.ocx");
Process.Start(string.Format("regsvr32 {0}", ocxPath));
|
|
|
|
|
I have the following code inside a Derived "Panel" control in C# 4:
public void ForceMoveScrollBar(int distX, int distY)
{
if (Math.Abs(distX) > HorizontalScroll.Maximum - HorizontalScroll.Value)
{
HorizontalScroll.Value = HorizontalScroll.Maximum;
}
else
{
HorizontalScroll.Value += distX;
}
}
It is meant to scroll the horizontal scroll inside the panel by a certain amont when a key is clicked on the keyboard.
However I have to tap the key twice for it to work, the first time make my panel flicker and the second time works.
The only fix I have is:
public void ForceMoveScrollBar(int distX, int distY)
{
if(Math.Abs(distX) >HorizontalScroll.Maximum - HorizontalScroll.Value)
{
HorizontalScroll.Value = HorizontalScroll.Maximum;
}
else
{
HorizontalScroll.Value += distX;
HorizontalScroll.Value += distX;
}
}
Why does it do this strange behaviour?
|
|
|
|
|
I'm assuming your using autoscroll
I have had better luck setting the postion
int distX += HorizontalScroll.Value;
int distY += VerticalScroll.Value;
AutoScrollPosition = new Point(x, y);
hope this helps
|
|
|
|
|
I saw this code
public class MyClass
{
protected static string a = "a";
public void DoStuff()
{
lock (a)
{
}
}
}
why not
public class MyClass
{
public void DoStuff()
{
lock (this)
{
}
}
}
CodingYoshi
Artificial Intelligence is no match for Human Stupidity.
|
|
|
|
|
Why would you lock an entire class when you are just working on a single object inside of the class? What if somebody else wants to work on a different part of it?
|
|
|
|
|
What if the method is changing a data member which is also used in another method? I guess it will be locked for that method as well, right? But why a static variable? I looked at the class and looks like it is only used for this purpose
CodingYoshi
Artificial Intelligence is no match for Human Stupidity.
|
|
|
|
|
There is only one a inside that class, however there could be many instances of that class; lock(a) is a lock shared by all instances, lock(this) isn't. Which one it should be depends on the data used inside the lock, is it instance-specific or is it global?
|
|
|
|