|
A simple token parser is decribed here[^].
There are tons more available on the internet.
You can even pay for some third party which will mean there is support provided as well.
|
|
|
|
|
I need a sample code to do an upload and download file from local machine to remote server using sftp or scp in genymed SSH2 . I am getting an exception "Cannot access a closed stream" while trying below code at get file method call, Connection is getting established successfully.
SCPClient Obj_SCP = new SCPClient(Obj_Conn); Obj_SCP.getFile(remotepath,localpath);
Obj_Conn.close();
|
|
|
|
|
how come adding "volatile" in below code snippet didn't help?
The output, without "volatile" would be like:
m=1,000,000, n=999,993
My expectation was, m=n=1,000,000 exactly if I added "volatile".
<br />
using System;<br />
using System.Collections;<br />
using System.Collections.Generic;<br />
using System.Linq;<br />
using System.Text;<br />
using System.Threading;<br />
using System.Threading.Tasks;<br />
<br />
namespace SimpleConsole<br />
{<br />
class Test<br />
{<br />
static int i = 0;<br />
<br />
static volatile int n = 0;<br />
static int m = 0;<br />
<br />
static Object SyncRoot = new Object();<br />
<br />
static void Main(string[] args)<br />
{<br />
Task[] Tasks = new Task[100];<br />
<br />
try<br />
{<br />
n = 0;<br />
m = 0;<br />
for (i = 0; i < 100; i++)<br />
{<br />
Task t = new Task(<br />
() =><br />
{<br />
for (int j = 0; j < 1000000; j++)<br />
{<br />
n++;
<br />
lock (SyncRoot)<br />
{<br />
m++;<br />
}<br />
}<br />
}<br />
);<br />
<br />
Tasks[i] = t;<br />
<br />
t.Start();<br />
}<br />
<br />
Task.WaitAll(Tasks);<br />
Console.WriteLine("n=" + n + ", m=" + m);<br />
<br />
Console.WriteLine("Hit any key to exit");<br />
Console.ReadLine();<br />
}<br />
catch (Exception Ex)<br />
{<br />
Console.WriteLine("Error in main: " + Ex.Message);<br />
}<br />
<br />
return;<br />
}<br />
}<br />
}<br />
dev
|
|
|
|
|
volatile won't help that - all it does is signal to the compiler that it may be changed outside so it can't optimise it into a local register. That is not the same as locking the value.
Don't forget, "n++" is just a syntactic sugar for "Fetch the value of 'n'. Add one to the value. Save the value back to 'n'"
Without locking, other threads can get in between the "Fetch" and the "Save" and do what they like to the value of 'n' without affecting the actual value used by your code because once it is fetched the changes will be ignored.
The only instant messaging I do involves my middle finger.
English doesn't borrow from other languages.
English follows other languages down dark alleys, knocks them over and goes through their pockets for loose grammar.
|
|
|
|
|
Try using the Interlocked.Increment method[^].
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I have an application that I need to monitor a database and get close to real time (<250ms) updates on a few tables.
Lets say I have to monitor 3 tables, not very big ones, less than 5000 rows but they are pretty active. I will have about 20 "clients" monitoring the three tables (so about 60 SqlDependency's).
Does anybody have experience with SqlDependency's and monitoring tables? Any performance issues with this? I know they say on MSDN that its not to be used with "hundreds or thousands of clients", but is 60 a rational number?
I'd run some tests, but there is a lot of framework yet to be put in before I'm there.
|
|
|
|
|
Ron Beyer wrote: is 60 a rational number
yes[^]
Sorry! (and I can't help you with your question - except to say I have seen posts by folk saying that using it has badly affected the performance of their database - but no facts or figures - I was looking at using it some time ago, but ended up not doing so.
MVVM # - I did it My Way
___________________________________________
Man, you're a god. - walterhevedeich 26/05/2011
.\\axxx
(That's an 'M')
|
|
|
|
|
how do I override the panel class to allow access in panel doublebuffer property in c#
code:
public class DoubleBufferedPanel : Panel
{
DoubleBufferedPanel()
{
this.DoubleBuffered = true;
this.SetStyle(ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.ResizeRedraw |
ControlStyles.ContainerControl |
ControlStyles.OptimizedDoubleBuffer |
ControlStyles.SupportsTransparentBackColor
, true);
}
}
the call is
Panel panel1 = new DoubleBufferedPanel();
error is:
'WindowsFormsApplication1.DoubleBufferedPanel.DoubleBufferedPanel()' is inaccessible due to its protection level
Please assist
From G
G
|
|
|
|
|
Your DoubleBufferedPanel constructor is not public - make it public with
public DoubleBufferedPanel()
|
|
|
|
|
Hi,
I have a panel and inside that panel there are 3 buttons which I have put them drag and drop inside that panel, now I add dynamically button4 inside panel which it's left is left of button3+button3.width, so when i want to check first index of controls inside panel then i get button which i added dinamically, instead of button4 i except to get button1.
So why i am getting this dinamically added button as first button of panel and i dont get button1 as first button inside panel?
Can anyone explain me this?
Best regards.
|
|
|
|
|
At design-time:
When you drag-drop Controls onto a Form, or into a container Control, like a Panel, they are written into the Designer.cs file in the order put on the Form.
When the WinForm "engine" lays out the Controls, then the last one created is effectively "in front of" the other Controls.
The ControlsCollection of a Form, or other container Control, is ordered by the z-order: so the last Control added, which is in front, is first.
If you change the z-order of a Control at design-time, its order in the ControlsCollection changes. Use 'BringToFront() it goes to the start of the ControlsCollection; use 'SendToBack(), and it goes to the end.
You can observe what happens at design-time by opening the Designer.cs file and examining the place in the file where Controls are added: change the z-order of one of the Controls you've put on the Form, and look at how the Designer.cs file has changed.
At run-time:
Controls you create and add to a Form, or container Control, are added to the end of the ControlsCollection of their container.
If you use 'BringToFront() on a dynamically created Control before you add it to the ControlsCollection of a container, it will have no effect, but will not cause an error.
If you use 'BringToFront() on a dynamically created Control after you add it to the ControlsCollection of a container, the Control will be at the 0th. element of the ControlsCollection.
Google CEO, Erich Schmidt: "I keep asking for a product called Serendipity. This product would have access to everything ever written or recorded, know everything the user ever worked on and saved to his or her personal hard drive, and know a whole lot about the user's tastes, friends and predilections." 2004, USA Today interview
|
|
|
|
|
I have a string variable which is stored in the form of 4,3,2,1 - is there some way I can sort this list so i can see it as 1,2,3,4
Thank you very much!
|
|
|
|
|
string source = "1,2,3,4";
string[] parts = source.Split(',');
Array.Sort(parts);
string result = string.Join(",", parts);
NB: This will sort using string comparison. That means that the string "9" will come after the string "10" . If that's not what you want, then you'll need to expand your specification.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Try this:
string reversedString = new string("4,3,2,1".Reverse().ToArray()); Note that this just literally reverses the order of the characters; it doesn't really "sort" in the technical sense of that word.
Google CEO, Erich Schmidt: "I keep asking for a product called Serendipity. This product would have access to everything ever written or recorded, know everything the user ever worked on and saved to his or her personal hard drive, and know a whole lot about the user's tastes, friends and predilections." 2004, USA Today interview
|
|
|
|
|
Just what i needed. Thank you.
If you don't mind me asking, how did you learn about this way to solve the problem? How long did it take you to figure out?
Instead of creating a new variable, i tried to reverse the existing variable, and put into a ViewState variable. That did not work. so, i went to what you have written, which works!!
of the form:
ViewState["questionumber"] = myquestionumber.Reverse().ToArray();
How did you know we have to create a new variable to do this? The fact we are treating it as new string?
|
|
|
|
|
vkEE wrote: How did you know we have to create a new variable to do this? The fact we are treating it as new string?
Funny question actually. My personal evolution in this, is that I started out using new variables and copies for everything. As we tend to divide a problem in smaller problems, transforming data (eg sorting a string) or other problems result in the creation of new variables to keep track of things (solutions to each smaller problem).
The more experience you gain through the years, the more compact I would start to develop, creating less and less variables.
|
|
|
|
|
LINQ - var sorted = new List<int>(str.Split(',').Select(s => int.Parse(s))).OrderBy(x=>x);
|
|
|
|
|
Anyone help me how can i handle multiple sensors fitted in chairs in auditorium that sends data that these chairs are busy or not ................................pls help ASAP
|
|
|
|
|
Please supply more information:
What type of sensor?
What type of interface?
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
The first thing you need to do is look at the interface provided by the sensor, and how it communicates with a computer. It's most unlikely that this would be via a COM port.
Veni, vidi, abiit domum
|
|
|
|
|
DateTime[] start = new DateTime[] { new DateTime(1990, 1, 1), new DateTime(1995, 1, 1), new DateTime(1995, 1, 1),new DateTime(2003, 1, 1) };
DateTime[] end = new DateTime[] { new DateTime(2000, 1, 1), new DateTime(2005, 1, 1), new DateTime(2005, 1, 1), new DateTime(2007, 1, 1)};
i cannot explain what i what to do in earlier question so i have array that contain start days and another array contain end day. and i should calculate lenght of days i dont need calculate overlap days
|-------------------|
|-----------------------|
|-----------------------|
|---------------------|
|
|
|
|
|
You can do this very easily using LINQ and TimeSpan.
First, get the minimum DateTime from the array(Min() ).
Then get the maxumim DateTime from the array (Max( )).
Using TimeSpan get the difference.
|
|
|
|
|
sorry but i did not understand you
|
|
|
|
|
Something like
accepted
If you want to find the earliest or latest Date:
DateTime earliest = arr.Min(record => record.Date);
DateTime latest = arr.Max(record => record.Date);
TimeSpan examples to calculate datetime difference - http://www.dotnetperls.com/timespan[^].
|
|
|
|
|
Try this:
List<TimeSpan> dateIntervals = endDates.Select((eDate, ndx) => eDate - startDates[ndx]).ToList(); The Linq 'Select function overload that supplies an index is available as of .NET FrameWork 3.5.
Google CEO, Erich Schmidt: "I keep asking for a product called Serendipity. This product would have access to everything ever written or recorded, know everything the user ever worked on and saved to his or her personal hard drive, and know a whole lot about the user's tastes, friends and predilections." 2004, USA Today interview
|
|
|
|
|