|
|
If that's the case, why does a height or width of two work? Aren't they drawing both sides with a minimum of 1 pixel each?
"If only one person knows the truth, it is still the truth." - Mahatma Gandhi Web - Blog - RSS - Math
|
|
|
|
|
I've got a class that uses a System.Threading.ReaderWriterLock .
class MyClass
{
int myReadLockCount;
int myWriteLockCount;
void DoSomeReads()
{
this.AcquireReaderLock();
try
{
...
}
finally
{
this.ReleaseReaderLock();
}
}
void DoSomeWrites() {...}
void AcquireReaderLock()
{
myRWLock.AcquireReaderLock(...);
Interlocked.Increment(ref myReadLockCount);
}
void AcquireWriterLock() {...};
void ReleaseReaderLock() {...};
void ReleaseWriterLock() {...};
}
During the course of running and debugging this application, I receive scenarios where myWriteLockCount variable is greater than 1! How can this be; isn't ReaderWriterLock supposed to allow one writer at a time?
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: How 'bout a little guitar now?
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
Judah Himango wrote: void ReleaseWriterLock() {...}; // releases the writer, decrements myWriteLockCount.
Just a guess, but shouldnt you be decrementing before releasing. You dont show the code, but the comment points to a possible cause.
|
|
|
|
|
Leppie, turns out a piece of my code was acquiring the writer lock multiple times from the same thread. So it was a coding mistake on my part, as I suspected. Anyways, thanks for the reply.
|
|
|
|
|
I have an appication that requires me to have a folder treeview simlar to
this[^]
Hpw do I make the same thing? I found a similar thing on planet source code, but it just gave me a treeview displaying folders. How can I get a control that allows me to select folders in the exact same way as in the screenshot.
|
|
|
|
|
Set the TreeView.CheckBoxes property to true.
|
|
|
|
|
I created a custom tab control and tab pages are added with a CollectionEditor. The CollectionEditor will add code and remove code when the add and remove buttons are used, but if the control is deleted on the form then the source code for the tab pages does not get removed. What needs to be done in order to remove the collections when the control is destroyed?
|
|
|
|
|
I have a small application. Is there any way I could cause my application to restart in the event of a crash instead of just closing?
|
|
|
|
|
I'm looking for an answer for the same question, but I'm checking now if I can use the event log in Windows to check if this application is closed by the user or in the event of crash, I'll keep searching and answer you if i got the answer, you can look for the same subject.
With my best hopes:
============--------
Mr.Jocker
--------============
|
|
|
|
|
Take a look at this, written by Tom Archer, a CPian.
Ed
|
|
|
|
|
You could do as Microsoft did and create a service(HangReporting Tool.) Just have the service look to see if the program exited anyway other than an exit code. You could have the program send the service a code saying it shutdown ok too.
|
|
|
|
|
I am trying to do a drag and drop. The idea is to drag from a listbox and create an instance of a label or a class that contains a label as a member, and drop the label to a panel to drop. Once on the panel the label need to moveable (drag and drop) in the panel. I also need to be able to store the x and y location of the label reletive to the panel. I can wait on the x and y stuff for now. I mainly need to get the label to appear in the panel with the text of the associate listbox item. Here is the code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace MullinsReqStar
{
public partial class Form1 : Form
{
Image bkgrnd_image;
Label[] lblList = new Label[25];
int count = 0;
public Form1()
{
InitializeComponent();
this.Text = "Mullins ReqStar";
}
private void lbItems_MouseDown(object sender, MouseEventArgs e)
{
lbItems.DoDragDrop(lbItems.Items[lbItems.SelectedIndex].ToString(), DragDropEffects.Copy | DragDropEffects.Move);
}
private void pnlImageBorder_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.Move;
//string strTest = lbItems.Items[lbItems.SelectedIndex].ToString();
//lblList[lbItems.SelectedIndex].Text = lbItems.Items[lbItems.SelectedIndex].ToString();
}
private void pnlImageBorder_DragDrop(object sender, DragEventArgs e)
{
//lblList[lbItems.SelectedIndex].Text = lbItems.Items[lbItems.SelectedIndex].ToString();
string strXTest = e.X.ToString();
string strYTest = e.Y.ToString();
lblList[lbItems.SelectedIndex].Location = new Point(e.X, e.Y);
}
}
}
Thanks
cbeasle1
|
|
|
|
|
|
I don't want to use any external programs or interfaces, i just need a solution without any user actions to obtain an image.
Thanks.
|
|
|
|
|
Hi,
I need to send right mouse click from within my program (C#.NET) to windows, so it will look like the user has right/left clicked with the mouse somewere on the desktop.
Any help will be highly appreciated
roy
|
|
|
|
|
I didn't try this, but it should look like:
<br />
[DllImport("user32.dll")]<br />
public static extern int SendMessage(IntPtr hWnd, UInt32 Msg, int wParam, int lParam)<br />
...<br />
public const UInt32 WM_LBUTTONDOWN = 0x201;<br />
public const UInt32 WM_LBUTTONDOWN = 0x202;<br />
...<br />
private void FakeClick( Control TargetControl, Point MouseLocation )<br />
{<br />
SendMessage(TargetControl.Handle,WM_LBUTTONDOWN,0,(MouseLocation.Y * 0x10000) + MouseLocation.X);<br />
SendMessage(TargetControl.Handle,WM_LBUTTONUP,0,(MouseLocation.Y * 0x10000) + MouseLocation.X);<br />
}<br />
In case that you don't have target Control try:
<br />
...<br />
public const UInt32 MOUSEEVENTF_LEFTDOWN = 0x0002;<br />
public const UInt32 MOUSEEVENTF_LEFTUP = 0x0004;<br />
...<br />
[DllImport("user32.dll")]<br />
private static extern void mouse_event( UInt32 dwFlags,UInt32 dX,UInt32 dY,UInt32 dwData,IntPtr dwExtraInfo);<br />
...<br />
public static void FakeClick(Point MouseLocation )<br />
{<br />
Cursor.Position = MouseLocation;<br />
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, new System.IntPtr());<br />
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, new System.IntPtr());<br />
}<br />
|
|
|
|
|
tnx. works just fine
|
|
|
|
|
Hello!
All icons of my toolbox are corrupted now (they looked fine before). Most of them now display a black mouse cursor, a paper sheet or an empty, gray field.
Have a look at this screenshot: Toolbox Bug[^].
Any idea how to get the correct icons back again?
Thanks in advance and best regards
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
|
Hi,
i have a datatable and have added new records to it.
I'm then applying an update using an adapter to send the records to the database:
mySqlDataAdapter.Update(myDataTable)
I know this Update function returns an integer base on the number of records successfully updated.
But for the ones that werent, is there a way of tracing which ones they were?
Andy
|
|
|
|
|
you have to play a bit with the RowState
I means, as you know, a DataTable is a collection of DataRows, each DataRow has a property called DataRowState, this value can be, CurrentRows, Inserted, Deleted... and so on.
In the moment you call the AcceptChanges of the DataSet ( or DataTable ) the DataRowState will be Current Rows, so you have to play with this before calling the DataAdapter.Update or the dataTable.AcceptChanges().
I send you code I did as sample for a fellow.
I hope it works
<br />
dstExample dst = new dstExample();<br />
dstExample.MyTableRow rowExample ;<br />
<br />
rowExample = dst.MyTable.NewMyTableRow();<br />
rowExample.MyField = "Field";<br />
dst.MyTable.Rows.Add ( rowExample );<br />
<br />
string s = rowExample.RowState.ToString();
<br />
string t = dst.MyTable.Rows [ 0 ].RowState.ToString();
<br />
<br />
bool h = dst.HasChanges ( );
bool j = dst.HasChanges ( System.Data.DataRowState.Added );
bool a = dst.HasChanges ( System.Data.DataRowState.Modified );
<br />
<br />
dst.MyTable.Rows [ 0 ].AcceptChanges();
<br />
h = dst.HasChanges ( );
j = dst.HasChanges ( System.Data.DataRowState.Added );
<br />
t = dst.MyTable.Rows [ 0 ].RowState.ToString();
<br />
rowExample = dst.MyTable.NewMyTableRow();<br />
rowExample.MyField = "Field";<br />
dst.MyTable.Rows.Add ( rowExample );<br />
<br />
h = dst.HasChanges ( );
<br />
rowExample = dst.MyTable.NewMyTableRow();<br />
rowExample.MyField = "Field";<br />
dst.MyTable.Rows.Add ( rowExample );<br />
<br />
dst.MyTable.Rows [ 2 ].AcceptChanges();
dst.MyTable.Rows [ 2 ][ 0 ] = "Value2";
<br />
s = dst.MyTable.Rows [ 1 ].RowState.ToString();<br />
t = dst.MyTable.Rows [ 2 ].RowState.ToString();<br />
<br />
h = dst.HasChanges ( );
j = dst.HasChanges ( System.Data.DataRowState.Added );
a = dst.HasChanges ( System.Data.DataRowState.Modified );
<br />
<br />
Regards
Ricardo Casquete
|
|
|
|
|
Hello!
Just coming in from the side, from the java-side.
Did see how one could cast from a String to an int ...
But how do I do the reverse, cast an int to a string ?
regards, i
"But if thought corrupts language, language can also corrupt thought." -George Orwell
|
|
|
|
|
use the ToString method:
int i = 7;
string s = i.ToString();
string s2 = ((int)7).ToString();
|
|
|
|
|
int myValue = Convert.ToInt32(myString);
string myStringValue = Convert.ToString(myValue);
protected internal static readonly ... and I wish the list could continue ...
-- modified at 10:59 Monday 27th March, 2006
|
|
|
|