|
I want to program a app that use Producer-Consumer Multithread model, I used to use WinAPI WaitForSingleObject & ReleaseSemaphore as a PV operator. Which .Net class can I use to implement to same ?
Thank you!
Let's roll!
|
|
|
|
|
See the class documentation for the System.Threading namespace in the .NET Framework SDK. There's lots of information in there. WaitHandle and its derivates have several wait methods that wait for the WaitHandle to be signaled. There's also classes for mutexes and monitors. If you use the lock keyword in C# against an instance of an object (a static object for synchronizing static resources, and an instance - if you prefer - for instance resources).
There's a good section on programming in .NET with threads. See Threading[^] in the .NET Framework SDK on MSDN Online for more information, which should be the first place you check (such as scanning what's available in the class library reference).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I need access to C# scripts for validating zip codes in three formats: ##### or #####-#### or
##### #### (no dash) & strings entered in forms @ ASP pages (running on .NET platform). Any help would be most appreciated! Many thanks!
Reed Eichner
reichner@satx.rr.com
|
|
|
|
|
Take a look at the validators -- RequiredFieldValidator, RangeValidator, and RegularExpressionValidator -- as they encapsulate all of the functionality that should allow you to determine if something is in the right format to be a zipcode. There are samples here on CP and in MSDN.
What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.
|
|
|
|
|
John: thanks for your feedback! However, I'm not a proficient coder...do you have the links to the respective script (pre-written code) that I can download & incorporate into an ASPX page?
Reed
Reed Eichner
reichner@satx.rr.com
|
|
|
|
|
Great - don't even try, and rip other people's code off for something so simple. You won't learn anything that way.
Try reading the class documentation for these validators in the .NET Framework SDK. They even include samples. And things like the RequiredFieldValidator are so simple - all you have to do is set the control name to validate (ControlToValidate property) and an error message (ErrorMessage property) at the bare minimum.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Reed,
Sorry, not off the top of my head. I'd have to do just what Heath suggests or look them up, too.
What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.
|
|
|
|
|
Dear, Sir
I forget use dispose() method after create a new instance in my app,
but I already sent my app to my customer.
The code below is some where I forget to use dispose() method.
private void button1_Click(object sender, System.EventArgs e)
{
Form2 frm = new Form2();
frm.Show.ShowDialog(this);
}
public void Connect()
{
if(idbConn != null)
idbConn.Close();
string sCnn = Report.SpecialFolder(ConnectionString_Long);
switch(_provider)
{
case EnumProviders.OLEDB:
idbConn = new OleDbConnection(sCnn);
break;
case EnumProviders.SQLClient:
idbConn = new SqlConnection(sCnn);
break;
case EnumProviders.OracleClient:
idbConn = new OracleConnection(sCnn);
break;
case EnumProviders.ODBC:
idbConn = new OdbcConnection(sCnn);
break;
}
idbConn.Open();
}
Plese tell me the risk
Thank You.
Sorry for bad English
|
|
|
|
|
The memory required for Form2 will continue to increase which each instantiation. Sounds like you need to release a patch. Fortunately, .NET facilitates versioning with .NET assemblies. You can release a new version of this assembly and either use the <assemblyBinding> configuration section in the app.config file, or use a publisher policy so that older assemblies can bind against the new version.
If you want to put these assemblies in the Global Assembly Cache, they must have a strong name. This means that they must use a version number (and you'd be wise to not use automatic versioning via the asterisk character because you can quickly loose control when you need to control version numbers) and be signed, either by specifying a filename in the AssemblyKeyFileAttribute or a container name in which the private key exists, named in AssemblyKeyNameAttribute .
For more information on assembly binding redirection, see Redirecting Assembly Versions[^] in the .NET Framework SDK on MSDN Online.
For more information on publisher policies, see Creating a Publisher Policy File[^] in the .NET Framework SDK on MSDN Online.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I'm currently in the middle of rewriting so software for work that deal with Rolm telephones. problem is, i never really messed with serial interfaces before and i am a little lost at how to ago about talking to the phones (basicly the phone tells the computer the phone number *like caller ID* and the computer tells the phone to log on and off or transfer calls).
any help would be really helpful.
Thanks again.
Joe
raged@ragedcom.com
|
|
|
|
|
There are several decent articles here on CodeProject about serial communications, including code samples and libraries. Just search for serial[^].
You can also use the MSComm control (Microsoft Communications control) as an interop assembly (right-click on your project, click Add Reference..., then find MSComm control or something like that and double-click it). There should be some articles on using this if you google for them.
As far as how to talk to the phone, you need to read the product documentation or visit the manufacturer's web site for that.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I'm trying out crystal reports in vs.net, with the wizard, and trying to use a stored procedure to populate the fields. I can select it as a table, but it's expand node does nothing when it comes to selecting the fields, and nothing is displayed at the end of the wizard, or when the app runs.
Does anyone have any ideas how to get the fields to be automatically extracted? The SP runs fine in query analyzer.
Thanks
|
|
|
|
|
Did you provide adequate credentials with which to log in to the database from the Crystal Reports designer?
Also, if you want any sort of portability of your code (i.e., not tied to a specific connection string), why don't you fill a DataSet from the stored proc and use that in the call to ReportDocument.SetDataSource ? The designer can bind nicely against DataSet s, and can even effectively make use of any relationships established in strongly-typed DataSet s (which make designing reports are them easier as well).
Something to consider...
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I was sa as the user on a local server. I saw the dataset option, but wasn't sure where or how to create the dataset (which is probably the answer). Do I create one inside the report and use that?
Thanks,
Chris
|
|
|
|
|
No, you create a typed DataSet in your project. Just right-click on your project (or subfolder) and clicked Add->Add New Item->DataSet. If you already have the tables you want added to your Solution Explorer (via a database connection), you can drag and drop the tables on the design surface. You can also set up relationships between table fields. You can easily fill that with a derivative of the DataAdapter class, then you instantiate your ReportDocument , call SetDataSource on it passing your typed DataSet , and display the report in whatever means you want.
And yes, if you're logging in as "sa" on the local db, you'll need to provide credentials since your using SQL (or whatever db) authentication as opposed to Windows integrated authentication (SSPI).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I got Object not set to an instance of object error. I have 1 Interface.dll, it contains interface classes for remote objects from RemoteObj.dll. I got problem when I use same namespace for interface and remote object classes. If I seperate them into 2 namespaces, will be fine.
Why? this is .NET restriction?
|
|
|
|
|
How can I retrieve ListViewSubItem's bounding rectangle?
ListViewItem has GetBounds, but I need bounds of specific subitem.
Thanks.
|
|
|
|
|
Adjust the rectangle based on the running sum of the column widths until that column. It's either that or going to the trouble of P/Invoking the SendMessage API and calling SendMessage with LVM_GETSUBITEMRECT . You'll also have to define the RECT structure. The System.Drawing.Rectangle is not an appropriate substitute. If you do it this way, you'll have little to no chance of being able to port your code to other platforms. The first way isn't hard and would work just fine.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I was already looking at the first method of doing it. I just thought that maybe there is some .net method somewhere that would give me that.
Thanks.
|
|
|
|
|
Anyone have code snipets or information on how to map a network drive in C# ?
|
|
|
|
|
Is there a particular reason why you need to map the network UNC to a drive letter? If not just stick with the UNC format. As far as I know all file manipulation works with UNC.
|
|
|
|
|
I'm with Tom on that. If you really need to (trying to substitute Windows with your application), you could always keep it simple:
Process.Start("net.exe", "use x: \\COMPUTERNAME\SHARENAME"); Otherwise, P/Invoke the NetUseAdd API from the Network Management APIs.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I'm trying to reconnect a mapped drive on user's machines. There are VPN issues with mappped drives being dropped.
P.S. I'm dealing with windows 98 machines....yuck
|
|
|
|
|
Hey
I have created a control with a ListView inside.
I have imported the control to a project in Visual C#,
I have also an own made balloon tooltip(PictureBox) in this form(project), this balloon tooltip will be visible only when the mose moves over the listView items in the control.
The Balloon tooltip will hover over an other part of the form(not in the controler), this is why i couldent have the Ballon ToolTip in the control.
No i have this problem
When i make a funktion(event) for mousemove(on the control in the project(form)) then it will just enter the funktion(event) when the mouse is going from one objet to another in the control, and not for every move(item).
I realy need it to throw this event every point the mouse is moving inside the control so i can fatch the info that the mouse is hovering above and display it in the Balloon tooltip outside the control.
it workt fine when i dident use a control, but then i just hade to use the MouseMove in the listview, now cant do that becourse the controler dont know of the ballontooltip and therby cant move or change it.
//Jimmy
PS Sorry for bad english
|
|
|
|
|
The List View common control - which the Windows Forms ListView encapsulates - handles most of this internally and some notification messages don't raise events as you might think (the MouseMove event is not overridden, and the List View common control handles this differently so the default behavior won't work).
Instead, you'll have to extend the ListView control, override WndProc , and handle the LVN_GETINFOTIP message (-157 on Windows (98/ME), -158 on Windows NT (NT/2000/XP/2003/and all future Windows OSes)). This is a WM_NOTIFY (message ID 78) notification message, so you'll actually get a pointer to an NMHDR struct in the LParam , which you can use Marshal.PtrToStructure to get.
For more information, see the documentation on the LVN_GETINFOTIP[^] notification message in the Platform SDK on MSDN Online.
You might also search CodeProject since there's many articles on customizing ListView , though I don't remember any dealing with tool tips off the top of my head.
Microsoft MVP, Visual C#
My Articles
|
|
|
|