|
And, what's the problem??
|
|
|
|
|
None. Is there a rule that forces a forum post to state a problem?
--
Affordable Windows-based CMS for only 99 €: try www.zeta-producer.com for free!
|
|
|
|
|
Heh, evidently not.
Just from the vague details I would suggest reorganizing the code so that the original poster's code does not run into a state where it is asking to "wait" in a thread unsafe place. Other than that, we need more details because none of us are mind readers.
|
|
|
|
|
I try to design an database application with 3 tier,design. So is it possible to pass all the Binding Context from User Interface Layer (UI Layer) to (DATA Layer) and then update the Binding Data in Logic Layer ?
Where DATA LAYER is a data class which is collection of the Field Name and Value only.
Sorry for my poor english..
|
|
|
|
|
What is a 3 tier,design ?
|
|
|
|
|
|
Thanks for da link man ,sorry i cant answer your question !
Did you check out my question about the "ticket system"
|
|
|
|
|
kakarato wrote:
Where DATA LAYER is a data class which is collection of the Field Name and Value only.
Yes. However, in your data class you'll need to implement properties for your fields. You class needs to implement [propertyName]Changed events for all your properties, and the property setters need to check if the value has changed and, if the xxxChanged event is not null, fire the event. Also, you need to initialize your fields usually.
If you don't do the event stuff, you won't get 2 way data binding.
Like this:
public class MyData
{
protected string myText;
public event EventHandler MyTextChanged;
public string MyText
{
get {return myText;}
set
{
myText=value;
if (MyTextChanged != null)
{
MyTextChanged(this, EventArgs.Empty);
}
}
}
public MyData()
{
myText="Initial Value";
}
}
I was going to write an article on "Intro to data binding" at some point!
Marc
My website
Latest Articles:
Undo/Redo Buffer
Memento Design Pattern
|
|
|
|
|
Thanks lot. Hope to able to read your new article as soon as possible. I think it may help me to be more understand on the 2 -way binding. Again Thanks.
|
|
|
|
|
Where can I find a c# open source version of a “Web based Ticket system” using SQL SERVER 2000 and .net.
So far I found only found php and mysql versions example: BugIn is a lightweight PHP4/ADODB (MySQL and PostgreSQL tested) bug/ticket/issue tracking system.
Please help !
Thank you in advance
e-mail yaggiza@yahoo.com
|
|
|
|
|
Hi,
In C#, I can send and retrieve email in Outlook easily by use of MAPIFolder, but I would like to know how can I instruct Outlook to check email?
thx
|
|
|
|
|
I tried runnin the code below. I want it to run the Print and dowmload threads as many times as I want.
The threads r properly synchronise with monitor fxns inside the print fxn.
-2 Thread[] myThreads = {new Thread( new ThreadStart (Print)),
-1 new Thread( new ThreadStart (Download))
0 };
1 myThreads[0].Start();
2 Thread.Sleep(50);
3
4 myThreads[1].Start();
5 Thread.Sleep(50);
6
7 foreach (Thread t in myThreads)
8 {
9 t.Join();
10 }
11
12 #region Start thread again (Code not yet working)
13 int cycle = 4;
14 while (cycle-- > 0)
15 {
16 myThreads[0].Start();
17 myThreads[1].Start();
18 foreach (Thread t in myThreads)
19 {
20 t.Join();
21 }
22 }
23 #endregion
24
25 Console.WriteLine("All threads are dead");
When this code gets to line 16 it throws exception that the I can't restart a dead thread
But i want the thread to start again (repeat) it's last job and die when I want it to die. I want to control my codes not the other way round
Can any body help get around this.
|
|
|
|
|
Intead of trying to start the thread again, you can move the code inside the thread function itself. Your thread function should look like
private void Download()
{
int cycle = 5;
while (cycle-- > 0)
{
}
}
In case you want to wait for all threads to Join before beginning the next iteration, you need to implement some sort of signaling (using AutoResetEvent or related classes).
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
|
Hello,
I'm trying to send the HDM_GETORDERARRAY message to my ListView.
The problem is that it requires a pointer to an array to write the indicies in. And I don't know how to pass an array of integers, so that I can read what's been written in it.
Any suggestions?
Thanks in advance!
|
|
|
|
|
I assume your already familiar with using unmanaged code (Introp calls etc.) Try this:
int[] MyArrayOfInts = ...<br />
<br />
fixed(int* p_MyArrayOfInts = MyArrayOfInts) <br />
{<br />
ThatFunction(p_MyArrayOfInts);<br />
}
Good luck.
|
|
|
|
|
OK, but the function prototype is:
protected static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, ref int lParam)
that is, I have to pass an integer, not an interger pointer...
|
|
|
|
|
iliyang wrote:
that is, I have to pass an integer, not an interger pointer...
The syntax is:
lResult = SendMessage(
(HWND) hWndControl,
(UINT) HDM_GETORDERARRAY,
(WPARAM) wParam,
(LPARAM) lParam
);
where lpiArray is: Pointer to an array of integers that receive the index values for items in the header.
So you do have to pass an array (even if the array is only one element long).
The pointer in the code of my previous post is merely a pointer to the FIRST integer in a row. From there the app can access the next integer, and the next, and so on. It will assume there are iSize integers in a row, starting at the address that is the pointer.
|
|
|
|
|
OK, 10x a lot! It worked finde when I called the function like this:
int[] MyArrayOfInts = ...<br />
<br />
fixed(int* p_MyArrayOfInts = MyArrayOfInts) <br />
{<br />
ThatFunction(*p_MyArrayOfInts);
}
|
|
|
|
|
Huh? That's not a pointer to an array you're putting in the function but the value of the first array element.
Anyhow, I was going to recommend an alternative method. The Interop-call to SendMessage should look something like this:
[DllImport("user32.dll"]<br />
public static extern int SendMessage(IntPtr hwnd, uint wMsg, IntPtr wParam, IntPtr lParam);
You can get an IntPtr to your array using Marshal.Copy(Int[] source, int startIndex, IntPtr destination, int length) .
I've never used Marshal.Copy before, so if you're decide to try it this way let me know how it turns out.
|
|
|
|
|
Yes, I know that I'm passing the first element of the array,
but I just tried and it worked fine
The second method (with the IntPtr) I found ealier but I didn't
know how to obtain an IntPtr object.
I suppose with the IntPtr is better too.
But how should I get an IntPtr object to copy the array into?
|
|
|
|
|
Just make one:
int[] MyArray = ...<br />
IntPtr MyPointer = IntPtr.Zero;
Marshal.Copy(MyArray, 0, MyPointer, MyArray.Length);
(Note: Don't confuse the marshal-call with the overload Marshal.Copy(IntPtr, int[], int, int) .)
|
|
|
|
|
Nope, Marshal.Copy throws a NullReference exception when passing
a null (0) IntPtr object.
So for now, the "mystical" solution works the best
|
|
|
|
|
You're right, my mistake. I wrongly assumed that the Copy method returns a pointer to the array. On second thought this isn't what Copy does at all. Instead you have to allocate some space yourself using Marshal.AllocHGlobal with the appropriate number of bytes. This gives you a valid IntPtr.
int Nr = ...;
int[] MyArray = new int[Nr];<br />
IntPtr MyPtr = Marshal.AllocHGlobal(Nr * sizeof(int))
Then call SendMessage with MyPtr.
Next use the Copy(IntPtr MyPtr, int[] MyArray, 0, MyArray.Length) method.
Finally use Marshal.FreeHAlloc.
|
|
|
|
|
Well, this time works but the values returned are messed.
But, you know, this does work fine:
_columnOrder = new int[this.Columns.Count];<br />
int size = 0;<br />
<br />
IntPtr pHeader = SendMessage(this.Handle, (int) Win32.Consts.LVM_GETHEADER, 0, ref size);<br />
<br />
SendMessage(pHeader, (int) Win32.Consts.HDM_GETORDERARRAY, _columnOrder.Length, ref _columnOrder[0]);
See the ref _columnOrder[0] in the second SendMessage call
|
|
|
|