 |
 |
Index ‹ DotNet ‹ Dotnet
|
- Previous
- 1
- Winforms >> how to: persist the DesktopBounds with a menu?hi all
i have a form that i would like to persist its desktopbounds.
however, upon each shut down + start up of the application
and the form,
the form's bottom grows by about the size of a menu.
this is obviousely an unwanted effect.
how can i persist the desktop bounds of my form with the menu?
assaf
- 2
- Visual C#.Net >> display user please wait, while backend is processingGurus,
I have a mainpage.aspx webform, in the page load of this page I am
displaying a text "Please wait connecting..." and then I want the user
to see this output on the WebForm, while I do some backend processing.
Once the backend processing is done I want to redirect the user to
another page e.g. "http://www.google.com".
I want to achieve the above without javascript, it should be pure
ASP.Net, is this possible ?
Can I show the user some message in a WebForm, while I do some backend
processing?
I tried
Response.write("Please wait connecting...");
Response.flush(); // This works.
// Do some backend process
Response.Redirect("http://www.google.com"); // This generates the error
"Cannot redirect after HTTP headers have been sent."
What am I missing?
Help is appreciated
Thanks,
Shailendra Batham
- 3
- Microsoft Project >> Fixed Duration and Work HoursQuestion on something I haven't been able to figure out and it happens
if the task is complete or in progress.
I have set the whole schedule to Fixed Duration but whenever I add or
delete a resource my start and finish dates change.
I thought with type set as Fixed Duration the dates shouldn't change
even if the overall work hours for the task did change.
I know Fixed Work will keep the work the same which should then keep
the date per se in check but I think Fixed Duration will do this job
better until I'm finished resource loading.
Any thoughts?
Cole
- 4
- ADO >> Progress bar doesn't incrementI created a windows form that has a progress bar on it. I am running a bunch of statements to update data on the database. I want the progress bar to increment (perform one step) after each update. The problem is that the progress bar doesn't move (it just sits there until the end) can anyone give me an example of how to accomplish this?
example:
progressBar1.Visible=true;
progressBar1.Show();
progressBar1.Maximum = 24;
progressBar1.Step = 1;
progressBar1.PerformStep();
Perform_update1;
progressBar1.PerformStep();
Perform_update2;
progressBar1.PerformStep();
Perform_update3;
etc.
thanks in advance
-Jeff-
- 5
- 6
- Visual C#.Net >> Continously Running ThreadDear:
I used to code a continously running thread in C++ like following:
Handle hStopEvent = CreateEvent(NULL,true,false,NULL);
UINT uOptional = 0;
_beginthreadex(NULL,0,wtInvestigate,(LPVOID)NULL,0,&uOptional);
unsigned _stdcall
wtInvestigate(LPVOID lpParams)
{
while(true)
{
DWORD dwThreadStatus = WaitForSingleObject(hStopEvent
,DELAY_TIME);
switch(dwThreadStatus)
{
case WAIT_OBJECT_0:
//TODO
break;
case WAIT_TIMEOUT:
//TODO
break
}
}
}
How can I achieve the same procedure in C#
- 7
- Visual C#.Net >> Seeking simple security exampleI am trying to create a couple of event and a memory mapped file for
interprocess communication that have security settings such that they can be
used between any two users. I have found some horribly complicated code on
the web and have got totally bogged down in scals and dacls. Can someone
point me at a nice simple example of how to set up security attributes for
unrestricted access?
--
Dave
- 8
- Visual C#.Net >> textbox og tal !!er der ikke en nem måde at få en textbox til kun at acceptere at der kun
bliver indtastet Tal 0-9 og som skal returnere en int værdi samtidig.
Textboxen skal bruges til et Pris Felt.. eller skal jeg lave min egen
validering af boxen og selv omformatere typen fra text til int .
ps. jeg bruger visual studio .net...
tak.
Tor Lund
- 9
- 10
- Dotnet >> how to set listview's backgound image?i tried to set listview's background image
(using managed C++)
first try, i maked bitmap and set back ground image like below code
but, it had no effect
LiveView * listViewJobTable
...
HBITMAP hBitmap =
LoadBitmap(g_hInstance,MAKEINTRESOURCE(IDB_BITMAPJOBLIST));
listViewJobTable->BackgroundImage = Image::FromHbitmap(hBitmap);
second try, i used win32 API ... using ListView_SetBkImage macro like below
code
but it had no effect too
HBITMAP hBitmap =
LoadBitmap(g_hInstance,MAKEINTRESOURCE(IDB_BITMAPJOBLIST));
LVBKIMAGE lVBKImage;
lVBKImage.ulFlags = LVBKIF_STYLE_NORMAL;
lVBKImage.hbm = hBitmap;
lVBKImage.pszImage= NULL;
lVBKImage.cchImageMax = 0;
lVBKImage.xOffsetPercent = 100;
lVBKImage.yOffsetPercent = 100;
ListView_SetBkImage((HWND)listViewJobTable->Handle.ToInt32(),&lVBKImage);
How Can I set ListView's Back ground Image using managed C++?
- 11
- ADO >> improving executenonquery timesHi,
We are new to ADO.NET, and any help would be appreciated.
The scenario is as follows: we have a large number of objects
(thousands) to write to a database. Each object has a method that
returns the SQL query which will update a relevant table in the
database.
We had opened a connection to the databse, and for each such string
did executenonquery (on that one connection). The results were
horrible. Then we had moved on to aggregating all the queries,
separated by newline in a one huge string (with StringBuilder of
course) and doing only one executenonquery per all the objects - that
was a big improvement.
Is the paradigm of doing one large executenonquery instead many small
ones, for one connection is indeed optimal ?
Is the paradigm of having one connection (instead of say, thousands,
each per object) optimal ?
Do you have any idea how the times may be improved further ? Is there
any other method ?
Alex & Misha
- 12
- 13
- 14
- 15
|
| Author |
Message |
wvantwiller

|
Posted: Tue Jan 18 00:38:22 CST 2005 |
Top |
Dotnet >> enumerate files
Hi,
I wanted to list all files in a directory so I found some code:
Dim t(), st As String
t = System.IO.Directory.GetFiles(System.IO.Directory.GetCurrentDirectory,
"*.txt")
Dim en As System.Collections.IEnumerator
en = t.GetEnumerator
While en.MoveNext
st = CStr(en.Current)
ComBoFilel.Items.Add(st)
End While
To add just the name of the file rather than its whole path, do I need to do
some string manipulation to find the last "\" or is there a simpler method
Thanks
DV
DotNet265
|
| |
|
| |
 |
Mattias

|
Posted: Tue Jan 18 00:38:22 CST 2005 |
Top |
Dotnet >> enumerate files
>To add just the name of the file rather than its whole path, do I need to do
>some string manipulation to find the last "\" or is there a simpler method
System.IO.Path.GetFileName()
Mattias
--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
|
| |
|
| |
 |
Doug

|
Posted: Tue Jan 18 01:04:49 CST 2005 |
Top |
Dotnet >> enumerate files
I solved this using:
Dim st As String
Dim di As DirectoryInfo = New DirectoryInfo(Directory.GetCurrentDirectory)
st = di.FullName
Dim fis As FileInfo() = di.GetFiles("*.txt")
Dim fil As FileInfo
For Each fil In fis
st = fil.Name.ToString
ComBoPalleteLbl.Items.Add(st)
Next fil
"Doug Versch" <EMail@HideDomain.com> wrote in message
news:eeVtMZR$EMail@HideDomain.com...
> Hi,
> I wanted to list all files in a directory so I found some code:
> Dim t(), st As String
>
> t = System.IO.Directory.GetFiles(System.IO.Directory.GetCurrentDirectory,
> "*.txt")
>
> Dim en As System.Collections.IEnumerator
>
> en = t.GetEnumerator
>
> While en.MoveNext
>
> st = CStr(en.Current)
>
> ComBoFilel.Items.Add(st)
>
> End While
>
> To add just the name of the file rather than its whole path, do I need to
do
> some string manipulation to find the last "\" or is there a simpler method
>
> Thanks
>
> DV
>
>
>
>
>
>
|
| |
|
| |
 |
| |
 |
Index ‹ DotNet ‹ Dotnet |
- Next
- 1
- Visual C#.Net >> Multiple ClickOnce manifests (slightly OT)OK heres an oddity...
I am using a ClickOnce (online only) deployment model; I have various
servers (primarily for different environments: testing, production etc), and
I want to have a *similar* manifest on each, with the main difference being
the config file (so that each connects to appropriate servers). To get
around the hashing on the config file, I simply publish the app (via
MSBuild) several times with different app.config contents each time.
The problem:
* (assume empty app-cache)
* Hit .application on download-server "A" - this downloads the app and
starts talking to web-service server "a" (correctly based on web.config)
* Close app
* Hit .application on download-server "B" - this then *also* starts talking
to web-service server "a", even though the config file on "B" says "b"
Obviously the runtime is deciding that they are the same app, and re-using
the cached copy.
So - can I fix it?
Is there any way (preferably automated either via some bespoke C# or just
MSBuild command-line parameters) of telling it that the two should be
treated separately? Preferably while using the same code-signing
certificate?
Thanks in advance,
Marc
- 2
- Winforms >> Adding handlers to events of a static variable in a classThe below code does not fire the event when I add a row
to the table on the form.
Is there an issue with static variable's events ?
If I attach and handler on the form, it works, but i dont
want to do it on every form, i want to do it in my class
with the static dataset in it..
Any suggestions?
---------
Public Class Test
Private Shared WithEvents _data As New dsCaptain
Public Shared ReadOnly Property Data() As dsCaptain
Get
Return _data
End Get
End Property
Private Shared Function loadCategory() As Integer
Return DataManager.adpCategory.Fill
(_data.Category)
End Function
Public Shared Function LoadCategories() As Integer
loadCategory()
AddHandler _data.Category.RowChanged, New
DataRowChangeEventHandler(AddressOf CategoriesChanged)
Return _data.cat_subCat.Count
End Function
Public Shared Sub CategoriesChanged(ByVal sender As
Object, ByVal e As System.Data.DataRowChangeEventArgs)
If e.Action = DataRowAction.Add Then
'MessageBox.Show("Category Added")
'make some calc, add a row to other tbl
'update database e.t.c.
End If
End Sub
End Class
-------
this class is called, int the form like:
---
Friend WithEvents SuperData As dsCaptain
Public Sub New()
MyBase.New()
InitializeComponent()
'------
SuperData = Business.Data
End Sub
Private Sub addRow_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles deleteRow.Click
mRow = SuperData.Category.NewRow
With mRow
.Name = "New Account"
.DateAdded = DateTime.Today
End With
SuperData.Category.AddCategoryRow(mRow)
End Sub
---
- 3
- Visual C#.Net >> How to import function from C++ dll and use them in c# code ?How cann I import & use these function from an old C++ dll ?
Only this, I've got are these two signatures of function I wannt use in
my C# app.
DllExport int DLLAPI drawImage( char *chemBuffer, char *queryBuffer,
char *chemFormat,
int showMapps, int showRkz,
int showSter, int showNumb,
int showInvRet, int queryDisplay,
int showResidue,
int canvasWidth,int canvasHeight,
HANDLE &imageHandle, int &imageBufferSize,
char *imageFormat) ;
DllExport int DLLAPI drawImageFile( char *chemBuffer, char *queryBuffer,
char *chemFormat,
int showMapps, int showRkz,
int showSter, int showNumb,
int showInvRet, int queryDisplay,
int showResidue,
int canvasWidth,int canvasHeight,
char *fileName,
char *imageFormat);
- 4
- Net Framework >> UI Process Application Block (UIPAB) - has anyone really used it?Hi, guys,
We're developing a Windows Forms application which includes managing
customers and their financial information, reporting, etc.
Just wondering if any of you have written a real Windows Forms
application (not a demo) using the UIPAB (whatever version).
If so, pls be as kind to tell me:
- how was the experience?
- what are the main advantages you felt? (not necessarily those
specified in the MS docs)
- was the cost in effort proportional to the gain (in
clarity/correctness/testability, whatever)
- any good starting points for info? (other than the UIPAB and its samples)
Thank you all very much and have a nice day
- 5
- 6
- 7
- Visual C#.Net >> PLS HELP! - Detect closing a UserControl before disposedHI,
I have a user control, say with one textBox.
I need the following: when the user closes form (either calling Form.Close, or pressing "X" or anyhow),
UserControl copies a file from a predefined folder to a folder in the textBox.
UserControl doesn't have a "Closing" event, so i tried to override UserControl.Dispose() :
// ==========================================================
protected override void Dispose( bool disposing )
{
// Here what i've added
File.Copy(SourceFile, TextFolder.Text + DestFile);
// If you check TextFolder.Text value, it's = "" for some reason...
// From here VS generated
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
// ==========================================================
The problem is that when i get to Dispose function, TextFolder.Text value is somehow blank.
I don't really understand why, as the UserControl is not disposed yet, but all controls located on the usercotrol,
lose values when get into Dispose.
Any ideas would be very, very, very appreciated!
Thank you,
Andrey
- 8
- Net Framework >> SoapTypeAttribute (System.Xml.Serialization) Example Code Fails[This is a repost, never got an answer the first time, 12/17/2004]
This is for Microsoft .NET Framework 1.1.
The example code given in the .NET Framework Class Library MSDN documentation
for SoapTypeAttribute Class [C#] compiles but fails at runtime. Can someone
possibly offer a fix, or a workaround? We need a fix or workaround in order
to proceed with using SoapTypeAttribute in our own code.
Here is the code, copied verbatim from the MSDN docs. When compiled as a
.NET Console application and run, it throws an exception like so:
[begin exception text]
An unhandled exception of type 'System.InvalidOperationException' occurred
in system.xml.dll
Additional information: There was an error generating the XML document.
[end exception text]
[begin MSDN example code]
using System;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
// The SoapType is overridden when the
// SerializeOverride method is called.
[SoapType("SoapGroupType", "http://www.cohowinery.com")]
public class Group
{
public string GroupName;
public Employee[] Employees;
}
[SoapType("EmployeeType")]
public class Employee{
public string Name;
}
public class Run
{
public static void Main()
{
Run test = new Run();
test.SerializeOriginal("SoapType.xml");
test.SerializeOverride("SoapType2.xml");
test.DeserializeObject("SoapType2.xml");
}
public void SerializeOriginal(string filename){
// Create an instance of the XmlSerializer class that
// can be used for serializing as a SOAP message.
XmlTypeMapping mapp =
(new SoapReflectionImporter()).ImportTypeMapping(typeof(Group));
XmlSerializer mySerializer =
new XmlSerializer(mapp);
// Writing the file requires a TextWriter.
TextWriter writer = new StreamWriter(filename);
// Create an instance of the class that will be serialized.
Group myGroup = new Group();
// Set the object properties.
myGroup.GroupName = ".NET";
Employee e1 = new Employee();
e1.Name = "Pat";
myGroup.Employees=new Employee[]{e1};
// Serialize the class, and close the TextWriter.
mySerializer.Serialize(writer, myGroup);
writer.Close();
}
public void SerializeOverride(string filename)
{
// Create an instance of the XmlSerializer class that
// uses a SoapAttributeOverrides object.
XmlSerializer mySerializer = CreateOverrideSerializer();
// Writing the file requires a TextWriter.
TextWriter writer = new StreamWriter(filename);
// Create an instance of the class that will be serialized.
Group myGroup = new Group();
// Set the object properties.
myGroup.GroupName = ".NET";
Employee e1 = new Employee();
e1.Name = "Pat";
myGroup.Employees=new Employee[]{e1};
// Serialize the class, and close the TextWriter.
mySerializer.Serialize(writer, myGroup);
writer.Close();
}
private XmlSerializer CreateOverrideSerializer()
{
// Create and return an XmlSerializer instance used to
// override and create SOAP messages.
SoapAttributeOverrides mySoapAttributeOverrides =
new SoapAttributeOverrides();
SoapAttributes soapAtts = new SoapAttributes();
// Override the SoapTypeAttribute.
SoapTypeAttribute soapType = new SoapTypeAttribute();
soapType.TypeName = "Team";
soapType.IncludeInSchema = false;
soapType.Namespace = "http://www.microsoft.com";
soapAtts.SoapType = soapType;
mySoapAttributeOverrides.Add(typeof(Group),soapAtts);
// Create an XmlTypeMapping that is used to create an instance
// of the XmlSerializer. Then return the XmlSerializer object.
XmlTypeMapping myMapping = (new SoapReflectionImporter(
mySoapAttributeOverrides)).ImportTypeMapping(typeof(Group));
XmlSerializer ser = new XmlSerializer(myMapping);
return ser;
}
public void DeserializeObject(string filename){
// Create an instance of the XmlSerializer class.
XmlSerializer mySerializer = CreateOverrideSerializer();
// Reading the file requires a TextReader.
TextReader reader = new StreamReader(filename);
// Deserialize and cast the object.
Group myGroup;
myGroup = (Group) mySerializer.Deserialize(reader);
Console.WriteLine(myGroup.GroupName);
}
}
[end MSDN example code]
Thanks.
--
David Bozzini
Susquehanna International Group
- 9
- Dotnet >> reuse business methods as DLL in another project ???Hi all,
I Have Core Project [3 tier Presentation-business-Data] include Core
functionality, I want to reuse the Core Business functions in another
project because the 2 projects using the same database.
Lets Say this is the Case:
CoreProject: Presentation->business->Data->DB
NewProject: Presentation->business->Data->DB
and
Presentation->CoreProject.business->CoreProject.Data->DB
My Question Is: How and where to add the Core business DLL in the new
project? And in case I want to add the Core business DLL reference to
the New Project Presentation there is conflict because of 2 businesses
DLL (the same name).
Thanks
Ashraf
- 10
- 11
- 12
- ADO >> Function to return BLOB valueSorry if this seems simple, but Im missing something here.
I have a function whose intent is to return a single BLOB (PDF file) from a
datareader. I will use this function in another function later down the call
stack with a StreamReader/Writer. Problem is, I dont know what I should
specify the first functions return type as. Is it a bitarray?
Private Function GetBLOBData() as ????????
--
Elliot M. Rodriguez, MCSD
*** It would take 227 cans of Mountain Dew to kill me***
- 13
- ADO >> From Counsole to MessageBox/*
Console::WriteLine() I am trying to use message box instead of
Console::WriteLine() to upgrade my code from just using the console to using
GUI.
In the bottom 2 lines, #1 works, but I have hard time to make # 2 works. Can
anybody give a hand here to make the information to be shown on the message
box instead of being shown on the console.
I am using visual C++ .NET 2003
Thanks
*/
#include "stdafx.h"
#include <gcroot.h>
#using <mscorlib.dll>
using namespace System;
using namespace System::Runtime::InteropServices;
typedef void* HWND;
[DllImportAttribute("User32.dll", CharSet=CharSet::Auto)]
extern "C" int MessageBox(HWND hw, String* text,
String* caption, unsigned int type);
__gc class MClass
{
public:
int val;
MClass(int n) //costructor
{
val = n;
}
};
class UClass
{
public :
gcroot<MClass*> mc;
UClass(MClass* pmc) //constructor
{
mc = pmc;
}
int getValue() //get function
{
return mc->val;
}
};
int _tmain()
{
Console::WriteLine(S"Testing...");
//Create a managed object and assign 3 to it
MClass* pm = new MClass (3);
//Create an unmanaged object and assign the value of the manged object (pm)
to it
UClass uc(pm);
Console::WriteLine(S"Value is {0}", __box(uc.getValue())); //<-------- This
will work # 1
//MessageBox(0, uc.getValue(), S"Message Box...", 0 ); //<------- this will
not work # 2
return 0;
}
- 14
- Dotnet >> Displaying a tooltip in a datagrid cell, tough problem, can it beI'm trying to work with a datagrid column in order to display a tooltip in a
datagrid cell. The reason I am doing this is because I have some long strings
being returned and I don't want the rows of the datagrid expaning down to
much. I basically want to display the first 50 characters in the grid cell
and then display the rest as a tooltip in the grid cell. I'm not sure if this
is possible but if anyone can help me do this I would be very grateful. I
have started this and am able to do the first part and get only the first 50
characters to be displayed back. I can also get the rest of the string set to
a new variable but I don't know how to use this properly and display a
tooltip with the string value for only that cell. Hope everyone knows what
i'm trying to do and that i've explained myself well enough. I've included
the code to show what I've down and also to give an idea of what i'm trying
to do. Any help at all would be very much appreciated.
HTML for the Column
<asp:TemplateColumn Visible="True" HeaderText="Start Date">
<ItemTemplate>
<%#getCompanyName(DataBinder.Eval(Container.DataItem,"CompanyName").ToString())%>
</ItemTemplate>
</asp:TemplateColumn>
Code Behind with comments of what I need to do
public string getCompanyName(string p_sFieldValue )
{
int iLength = p_sFieldValue.Length;
int iLengthToUse = 0;
int iRemainder = 0;
if (p_sFieldValue == DBNull.Value.ToString())
{
return string.Empty;
}
else if(iLength > 50)
{
//In here I basically would like to only return the first
//50 characters of the string and then for the rest of the
//string Iâ??d like the details to be displayed in a tooltip
//for that cell. I know the below code wonâ??t work because
//of the e but its just to give an idea of what I need to do.
//If someone knows how I can display a tooltip for the rest
//of the string Iâ??d be really really grateful
//Iâ??m not sure if this can be done but if anyone has any
//ideas Iâ??d really appreciate it. Thanks
/*
iRemainder = p_sFieldValue.Length - 50;
string sTooltipText = p_sFieldValue.Substring(50,iRemainder);
if(e.Item.ItemType == ListItemType. SelectedItem)
{
e.Item.Cells[1].ToolTip = sTooltipText;
}
*/
//This bit works fine
string sCompanyName = p_sFieldValue.Substring(0,50); return
sCompanyName;
}
else
{
return p_sFieldValue;
}
}
- 15
- Visual C#.Net >> PerformanceCountersI'm having issues getting some custom performance counters to work.. Here's
what I'm trying to do...
I want to create one category with two CountPerTimeInterval32 counters,
which represent an interface.. For each implementation I want to add a new
instance for both counters so each implementation can be tracked
seperately.. The category and counters (minus the instances) show up in the
in the performance object, although the bases do not. When I try to
increment the counters nothing shows up, here is my implementation, please
help...
TIA,
Dan B
Imports System
Imports System.Collections
Imports System.Collections.Specialized
Imports System.Diagnostics
Imports MNCAppServices
Public Class Collector
Private pcCategory As PerformanceCounterCategory
Private pcBDOGet As PerformanceCounter
Private pcBDOGetBase As PerformanceCounter
Private pcBDOSave As PerformanceCounter
Private pcBDOSaveBase As PerformanceCounter
Sub New()
SetupCategory()
End Sub
Private Function SetupCategory() As Boolean
Try
If Not PerformanceCounterCategory.Exists("MNC BDO Statistics") Then
Dim CCDC As New CounterCreationDataCollection
'create counters
Dim cptBDOGet As New CounterCreationData("BDOGet", "Tracks calls to BDOGet
by time interval.", PerformanceCounterType.CountPerTimeInterval32)
CCDC.Add(cptBDOGet)
Dim cptBDOGetBase As New CounterCreationData("BDOGetBase", "Tracks calls to
BDOGet by time interval.", PerformanceCounterType.AverageBase)
CCDC.Add(cptBDOGetBase)
Dim cptBDOSave As New CounterCreationData("BDOSave", "Tracks calls to
BDOSave by time interval.", PerformanceCounterType.CountPerTimeInterval32)
CCDC.Add(cptBDOSave)
Dim cptBDOSaveBase As New CounterCreationData("BDOSaveBase", "Tracks calls
to BDOGet by time interval.", PerformanceCounterType.AverageBase)
CCDC.Add(cptBDOSaveBase)
' Create the category.
PerformanceCounterCategory.Create("MNC BDO Statistics", "Collects statistics
about Business Data Object Usage.", CCDC)
CreateCounters()
Return True
Else
GetCategoryRef()
GetCountersRef()
Return True
End If
Catch ex As Exception
Utility.LogException(ex)
Return False
End Try
End Function 'SetupCategory
Private Sub CreateCounters()
' Create the counters.
pcBDOGet = New PerformanceCounter("MNC BDO Statistics", "BDOGet",
"CustomerContact", False)
pcBDOGet.ReadOnly = False
pcBDOGet.RawValue = 0
pcBDOGetBase = New PerformanceCounter("MNC BDO Statistics", "BDOGetBase",
"CustomerContact", False)
pcBDOGetBase.ReadOnly = False
pcBDOGetBase.RawValue = 0
pcBDOSave = New PerformanceCounter("MNC BDO Statistics", "BDOSave",
"CustomerContact", False)
pcBDOSave.ReadOnly = False
pcBDOSave.RawValue = 0
pcBDOSaveBase = New PerformanceCounter("MNC BDO Statistics", "BDOSaveBase",
"CustomerContact", False)
pcBDOSaveBase.ReadOnly = False
pcBDOSaveBase.RawValue = 0
End Sub 'CreateCounters
Private Sub GetCountersRef()
' Create references to counters.
Dim objCnt As PerformanceCounter
For Each objCnt In pcCategory.GetCounters
Select Case objCnt.CounterName
Case Is = "BDOGet"
pcBDOGet = objCnt
pcBDOGet.ReadOnly = False
Case Is = "BDOGetBase"
pcBDOGetBase = objCnt
pcBDOGetBase.ReadOnly = False
Case Is = "BDOSave"
pcBDOSave = objCnt
pcBDOSave.ReadOnly = False
Case Is = "BDOSaveBase"
pcBDOSaveBase = objCnt
pcBDOSaveBase.ReadOnly = False
End Select
Next
End Sub 'CreateCounters
Private Sub GetCountersRef(ByVal InstanceName As String)
' Create references to counters.
Dim objCnt As PerformanceCounter
For Each objCnt In pcCategory.GetCounters(InstanceName)
Select Case objCnt.CounterName
Case Is = "BDOGet"
pcBDOGet = objCnt
pcBDOGet.ReadOnly = False
Case Is = "BDOGetBase"
pcBDOGetBase = objCnt
pcBDOGetBase.ReadOnly = False
Case Is = "BDOSave"
pcBDOSave = objCnt
pcBDOSave.ReadOnly = False
Case Is = "BDOSaveBase"
pcBDOSaveBase = objCnt
pcBDOSaveBase.ReadOnly = False
End Select
Next
End Sub
Private Sub GetCategoryRef()
Dim objCategory As PerformanceCounterCategory
For Each objCategory In PerformanceCounterCategory.GetCategories
If objCategory.CategoryName = "MNC BDO Statistics" Then
pcCategory = objCategory
End If
Next
End Sub
Public Sub IncrementSaveCounter(ByVal InstanceName As String)
If pcCategory.InstanceExists(InstanceName) Then
GetCountersRef(InstanceName)
pcBDOSave.Increment()
End If
End Sub
Public Sub IncrementGetCounter(ByVal InstanceName As String)
If pcCategory.InstanceExists(InstanceName) Then
GetCountersRef(InstanceName)
pcBDOGet.Increment()
End If
End Sub
End Class 'App
|
|
|