|
Ignore the previous answer!
I forgot the folder path was there...
Best way is to do this:
string strreg = @"^v\d\.\d\d{2}$";
arrVersionsDirectories = Directory.GetDirectories(A_ParentDir)
.Where(path => Regex.IsMatch(Path.GetFileName(path), strreg))
.ToList()
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Hi, I am coding two .cs files into one dll but Visual Studio 2012 sends the following error message:
The name 'Beeper' does not exist in the current context.
The first file codes like this:
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Windows.Forms;
namespace Hum
{
public class Singer
{
public void Beeper(long frequency, int msDuration, long volume)
{
}
}
}
When I do the function call in the second .cs file:
Singer cacophony = new Singer();
int Duration = 300000;
ThreadStart Wfrequency = new ThreadStart(Beeper(nw, Duration, 16383));
Thread childThreadW = new Thread(Wfrequency);
childThreadW.Start();
It gives the error.
I know I am missing something very basic.
Thanks for the help.
|
|
|
|
|
Beeper is a member function of Singer (the class)... Calling it like Beeper alone will only work when you are in the context of Singer (from other members for instance).
If you are out of that context you have to tell the compiler the new/actual context... in your case cacophony ...
So the code should be like this:
new ThreadStart(cacophony.Beeper(...));
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
Ok, now the error is:
Method name expected.
Any ideas?
|
|
|
|
|
|
Sorry, but please walk me through it.
The example and my code look identical to me.
|
|
|
|
|
You really need to understand the basics of c# before you try anything half-way complicated. We can't solve every basic problem you have. Get a book on c# and learn the fundamentals so you can solve these issues yourself, a forum is not a good place to learn something from scratch.
|
|
|
|
|
Please show the code and the error message, we cannot see your screen.
|
|
|
|
|
This exact line of code is where the error occurs:
ThreadStart Wfrequency = new ThreadStart(cacophony.Beeper((int)nw, Duration, 16383));
Specifically the ThreadStart() function.
The error is:
Method name expected.
|
|
|
|
|
As shown on the link that Peter already gave you, the delegate creator needs the method name only. So your code should be:
ThreadStart Wfrequency = new ThreadStart(cacophony.Beeper);
See also Creating Threads and Passing Data at Start Time[^].
|
|
|
|
|
Ok, but as you may see. The Beeper(); Function inputs 3 parameters (frequency, Duration and volume).
The
ThreadStart(cacophony.Beeper); does not pass these parameters or am I missing something?
|
|
|
|
|
Member 12244972 wrote: or am I missing something? Yes, what you are creating here is a delegate, not an immediate call to the beeper method. You need to spend more time reading the links you have been given to understand how delegates are used. See the tutorials on Events and Delegates at C# Tutorials (C#)[^].
|
|
|
|
|
Ok, removed the
ThreadStart();
and implemented a lambda...
Thread childThreadW = new Thread(unused => cacophony.Beeper((int)nw, Duration, 16383));
and my code builds fine now.
Thank you all!
|
|
|
|
|
|
"don't work" is very vague. What exactly does that mean? What line of code? Any error messages? Do you have the library required to read these files?
|
|
|
|
|
While I'm generally in favor of Controls letting the user do anything ... and, then, pay the price for doing something stupid, I'm just curious if the WPF and ASP.NET Controls allow the same.
I have a bright student who keeps asking me why they can create multiple nodes whose text (what appears on the Node Label) is identical; I tell them: "you think that's crazy: how about an entire TreeView where every Node has both identical Text and Name (Key) values ?" Then, I show them how to create a sub-classed TreeView that prevents identical Text, or Name (Key) values.
thanks, Bill
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
|
|
|
|
|
BillWoodruff wrote: I have a bright student who keeps asking me why they can create multiple nodes whose text (what appears on the Node Label) is identical ..because that would be a limitation that does not bring us much in return, but it would be easy to prevent loading duplicates yourself.
I agree that the user should be able to uniquely identify an item before interacting with it; a identity-column should not be visible and is not enough for a user to distinguish between items - so, how do you convey that there are three fields in your view that make an item unique?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I love the treenode object I scrounged from one of Josh Smiths articles, tag property as an object and shove the underlying object for the node into there.
Extend it with a few properties and you can support a treelistview.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
I'm trying to use the SendMessage for sending memory stream. I did some code, but not working. Here's my code.
stream.Seek(0, SeekOrigin.Begin);
int dataSize = Convert.ToInt32(stream.Length);
byte[] byteArray = new byte[dataSize];
int count = stream.Read(byteArray, 0, 20);
while(count < stream.Length)
{
byteArray[count++] = Convert.ToByte(stream.ReadByte());
}
IntPtr ptrData = Marshal.AllocCoTaskMem(dataSize);
Marshal.Copy(byteArray, 0, ptrData, dataSize);
CopyDataStruct cds = new CopyDataStruct
{
cbData = dataSize,
dwData = (IntPtr)1,
lpData = ptrData
};
SendMessage(hWnd, WM_COPYDATA, 0, cds);
Thanks
|
|
|
|
|
|
Could I know which line you are pointing to, please?
|
|
|
|
|
The CopyStruct parameters have the length set as 1, but I think it needs to be the length of the data. The documentation is unfortunately not very clear, so I suggest you try a few different things.
[edit]
Looking again, you have cbData and dwData in the wrong order.
[/edit]
|
|
|
|
|
You mean this?
cds.dwData = dataSize;
cds.cbData = (IntPtr)1;
|
|
|
|
|
Have you tried it, and did it work?
|
|
|
|
|
That didn't work. dwData should be (IntPtr)copyDataType which worked.
Thanks
|
|
|
|