|
i have try something that i think is correct but in the line sendBuffer.Enqueue(newPacket) error received: Failed enqueueing to SendQueue
using (PacketSendBuffer sendBuffer = new PacketSendBuffer((uint)capLength))
{
int numPackets = 0;
Packet packet;
while (inputCommunicator.ReceivePacket(out packet) == PacketCommunicatorReceiveResult.Ok)
{
IpV4Layer ipLayer = (IpV4Layer)packet.Ethernet.IpV4.ExtractLayer();
ipLayer.Destination = new IpV4Address("11.12.13.14");
EthernetLayer ethernet = (EthernetLayer)packet.Ethernet.ExtractLayer();
PayloadLayer payload = (PayloadLayer)packet.Ethernet.Payload.ExtractLayer();
Packet newPacket = PacketBuilder.Build(DateTime.Now, ethernet, ipLayer, ipLayer, payload);
sendBuffer.Enqueue(newPacket);
++numPackets;
}
outputCommunicator.Transmit(sendBuffer, isSync);
}
|
|
|
|
|
Have you tried the PCap site? Don't they have a support forum?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
yes they have but the forum not so effective (lack of users)
|
|
|
|
|
i have a float type of variable i.e float t1=200.36 and t2=300.62. now i want to roundoff these two variables to their nearest degit.
I want to show the information like this:
t1=200.36 roundoff=-0.36 total=200
t2=300.62 roundoff=+0.38 total=301
|
|
|
|
|
Look here:
Floor[^]
Ceiling[^]
Round[^]
Then you can take the difference of the original with the rounded value.
Hope this helps.
V.
|
|
|
|
|
See this code to get the idea:
double t1 = 200.36;
double t2 = 300.62;
int t11 = (int)Math.Round(t1, 0);
int t21 = (int)Math.Round(t2, 0);
MessageBox.Show("t1=" + t1.ToString() + " roundoff=" + (t11 - t1).ToString("0.00") + " total=" + Math.Round(t1, 0).ToString());
MessageBox.Show("t2=" + t2.ToString() + " roundoff=" + (t21 - t2).ToString("0.00") + " total=" + Math.Round(t2, 0).ToString());
|
|
|
|
|
I want to add the following
What is required when the number is half i.e. 200.5. Whether 200 or 201?
By default Math.Round follows
MidpointRounding.ToEven enumeration value.
double number = 200.5;
Console.WriteLine (Math.Round(number,0));
Console.WriteLine (Math.Round(number,0, MidpointRounding.AwayFromZero));
double number2 = 201.5;
Console.WriteLine (Math.Round(number2,0));
Console.WriteLine (Math.Round(number2,0, MidpointRounding.AwayFromZero));
So, if the next higher number is required always, when the value is half way, then
MidpointRounding.AwayFromZero is to be used.
modified 30-Mar-12 10:15am.
|
|
|
|
|
Try this code.. :
double g = [any no];//should be of double
double L = Math.Floor(g);
if (g-L<0.5)
{
k = (int)(L);
}
else
{
k = (int)(L + 1);
}
now k have ur nearest integer..
|
|
|
|
|
Hi All,
I am building a windows tool for which I require a text area control where i can format the text such as color, size etc. but the formatted text should be readable as HTML in the codebehind.
Is there any such tool?
Jack Sparrow
--------------------------------------
Defeat is not the worst of failures. Not to have tried is the true failure.
|
|
|
|
|
Ramkithepower wrote: Is there any such tool?
There should be some HTML-editor controls here on CodeProject
Bastard Programmer from Hell
|
|
|
|
|
I have a control DateTimeInput, when I run up, then assign the current date by default, but when his days in DateTimeInput clrear then how do you know to enter the date again? I checked the way DateTimeInput.Text == "" or DateTimeInput.Value.ToString () == "" but it does not understand. Thanks to all who know you helped with.
|
|
|
|
|
i can give two ways
1--->u can use directly system date time
2---->if u use any control for date and time see the database table variable ...if it is given as date then check the properties of u r control with code....
I hope it will help u????????///
|
|
|
|
|
What kind of control is it?
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
datetimeinput of dotnetbar.
|
|
|
|
|
every one please help me
i can n't write program to control and management multithreading
and transfer variables between threads
|
|
|
|
|
Do you have a specific question or problem? That would assist us in trying to help you.
/ravi
|
|
|
|
|
here is my code, word is a string array. i want to convert this code into parllel ,so that i can reduce time and use all processor of my i5 processor system..
for (int i = 0; i < k1; i++)
{
for (int j = 0; j < k1; j++)
{
num[j][i] = Convert.ToInt32(words[count]);
count++;
}
}
can anyone help me out in this????
|
|
|
|
|
Easiest solution is to convert it to a parallel loop[^], available in .NET 4;
using System;
using System.Threading.Tasks;
class Demo
{
int N = 1000;
void TestMethod()
{
Parallel.For(0, N, (i, loopState) =>
{
Console.WriteLine(i);
if (i == 100)
{
loopState.Break();
}
});
}
}
If you need more control, you'd typically use a thread[^].
Bastard Programmer from Hell
|
|
|
|
|
I tried this code.. but i m getting high execution time than its sequential code.. and parllel execution should take less execution time than sequential code..
|
|
|
|
|
KUNWAR999 wrote: and parllel execution should take less execution time than sequential code..
..if the problem can be solved using parallel threads, and only when implemented correctly. The example was the easiest method, but it's only a shorthand for a specific type of problem.
You can spawn threads[^] to run code concurrently. It's usually the OS that decides on which core the thread runs, but I believe you can set it's affinity.
Bastard Programmer from Hell
|
|
|
|
|
i hv tried it one more way as using #pragma omp parllel ..
but vs2010 saying that its unrecognized concept..
actually i am avoiding using threads because i want to use parllel processing in processor directly..
|
|
|
|
|
KUNWAR999 wrote: actually i am avoiding using threads because i want to use parllel processing in processor directly..
..and how would you do that?
Bastard Programmer from Hell
|
|
|
|
|
Can you please explain or give a link to understand basic concept of Reflections in c#.
Thanks, Ravi
|
|
|
|
|
|
See this[^] tutorial.
/ravi
|
|
|
|