| Continously Running Thread |
|
 |
Index ‹ DotNet ‹ Visual C#.Net
|
- Previous
- 1
- Visual C#.Net >> How to make SoapHttpClientProtocol create different TCP connection for web service invocation?I use VS auto generated code to invoke a internal network webservice.
The auto-generated code use class SoapHttpClientProtocol to do Soap-on-
http communication. It turns out that for single
SoapHttpClientProtocol instances, TCP connection is always maintained
for reuse. This is understandable. Now, I have one load balancer
between client and backend webservice cluster, so, single TCP
connection for single invocation is prefer-ed.
How to make it create TCP connection for one method invocation and
then close it?
Thanks,
- 2
- 3
- 4
- 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
- 5
- 6
- 7
- 8
- 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
- 9
- 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++?
- 10
- Dotnet >> Crytsal Reports LinesI var a report which is designed to represent a form. The detail rows need
to be seperated by lines. I am recieving mmy data accirately from a SQL
database. The report works fine; however whjen I place the line underneath
the row of fields the fields appear to be blank or covered up. in other
words all or parts of the data seem to disappear. Any ideas???
Thanks
Rick
- 11
- Microsoft Project >> Material Cost Input and CalculationOur Material Cost View is not acting consistently and am wondering if anyone
knows what the reason and/or fix might be.
In some instances it is working as desired where once the material resource
is assigned to a task you must enter the units into Actual Work then Actual
Cost is calculated. Entering directly into Actual Cost is blocked.
In other instances it will block from allowing input into Actual Cost on the
first input column then will allow it after that. If data is input into the
Actual Cost field Actual Work is not calculated and the 2 become out of sync.
In even other instances it allows input into Actual Cost on the first try.
The problem does not seem to be project specific either. Sometimes it works
OK on a project and other times it doesn't. I have not been able to identify
any commonality in occurance.
Thanks,
Debbie
--
Debbie P
- 12
- 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-
- 13
- 14
- 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
- 15
- Microsoft Project >> Resource across projectsI'm getting there - thanks to this forum!
I now have a shared resource across 3 projects (one of which is absence,
i.e. sickness & holidays!)
If I open my resource file (in resource usage view), I can see by person,
all the work that they have done across the projects in a week (to make sure
it adds up to 35 hours) then by project I can see the progression - LOVELY
But, of course, a problem remains (!), since I receive worksheets (across
the projects) by man, I would like to be able to enter the hours worked from
the resource usage view in the shared resource file, and then have that
update the hours worked in all the projects (and consequently hours remaining
etc etc) - I don't seem to be able to do this (it doesn't have any effect,
and will not save), I have to go into each project & update them individually
(which then updates the shared resource file)
I'm sure there must be a way of doing this, all help appreciated
Thanks
--
Helen
|
| Author |
Message |
bullbreaker

|
Posted: Mon Jan 03 09:49:25 CST 2005 |
Top |
Visual C#.Net >> Continously Running Thread
Dear:
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#
DotNet368
|
| |
|
| |
 |
Jon

|
Posted: Mon Jan 03 09:49:25 CST 2005 |
Top |
Visual C#.Net >> Continously Running Thread
Raed Sawalha <EMail@HideDomain.com> wrote:
> I used to code a continously running thread in C++ like following:
<snip>
> How can I achieve the same procedure in C#
Just write a never-ending method, and create a thread to run that
method in the normal way. I very rarely write methods like that though
- the thread should usually watch for a certain condition at which
point it will shut down gracefully.
See http://www.pobox.com/~skeet/csharp/threads/ for more threading
information.
--
Jon Skeet - <EMail@HideDomain.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
|
| |
|
| |
 |
| |
 |
Index ‹ DotNet ‹ Visual C#.Net |
- Next
- 1
- 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
- 2
- 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
- 3
- 4
- 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***
- 5
- 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
---
- 6
- 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
- 7
- 8
- 9
- Dotnet >> enumerate filesHi,
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
- 10
- 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
- 11
- 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);
- 12
- 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
- 13
- 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
- 14
- 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
- 15
- 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
|
|
|