Click here to Skip to main content
15,887,683 members
Home / Discussions / WPF
   

WPF

 
QuestionMessage Removed Pin
13-Jul-09 10:59
professionalN_tro_P13-Jul-09 10:59 
AnswerRe: WPF animation background processing Pin
Christian Graus13-Jul-09 11:25
protectorChristian Graus13-Jul-09 11:25 
QuestionDataGrid Bindings not working Pin
Jacobus0113-Jul-09 4:06
Jacobus0113-Jul-09 4:06 
AnswerRe: DataGrid Bindings not working Pin
laprathab13-Jul-09 21:50
laprathab13-Jul-09 21:50 
GeneralRe: DataGrid Bindings not working Pin
Jacobus0113-Jul-09 22:36
Jacobus0113-Jul-09 22:36 
QuestionDisplaying Data fetched asyncronously Pin
Adriaan Davel12-Jul-09 20:27
Adriaan Davel12-Jul-09 20:27 
AnswerRe: Displaying Data fetched asyncronously Pin
Mark Salsbery15-Jul-09 10:13
Mark Salsbery15-Jul-09 10:13 
GeneralRe: Displaying Data fetched asyncronously Pin
Adriaan Davel15-Jul-09 19:46
Adriaan Davel15-Jul-09 19:46 
Hi Mark, again thanks for the reply, quite a bit to work through Smile | :)

I've worked through an example thats very close to sync calls to WCF in Silverlight, but it still would have been much better to be able to do a true sync call from the UI thread. For example, I create a new instance of a class and send it to the WCF service to save it to the SQL database. In my DAL I get the IDENTITY column value after the insert, and use it as a unique Id on the class (also use it for foreign keys etc). The problem is to get the identity value back across the service (with a return value) and assign the value back to the class instance to ensure that I can use the Id on my client.

I've acheived it with the below (rather elaborate) code block (which also needs a bit of work still), but the problem is that this code HAS to run inside my control event, I cannot abstract it from the control and re-use / recall the same code in other controls as the worker thread needs to invoke the UI code else its not sync anymore...

It would have been so easy to just make a sync call, blocking the UI thread till a response is received, and carrying on, just like Win / Web / WPF can do with WCF calls... The whole concept of preventing the developer from blocking the UI thread during data calls is bizarre to me. (In my uneducated opinion Microsoft is trying to make SL UI as cool / fluent as possible for marketing, at huge expense to "normal" programming methods). I love the fact that async calls are so easy to do, and I believe in async calls, but to make sync impossible is bizarre... I always try to write my code to "look like" the business process / logic, and if you are telling a busines that its impossible to make one process wait for the previous to finish, you'll be thrown out...

Anyway, enough complaining, thanks for the usefull comments, much appreciated

string description = txtDescription.Text;
string name = txtName.Text;

ThreadPool.QueueUserWorkItem(delegate
{
	InfonMachineActiveDefinition newInfonMachineActiveDefinition = new InfonMachineActiveDefinition																{																				ContainingBranch = GlobalCache.CurrentBranch,														Description = description,
										Name = name,
										CreatedDateTime = DateTime.Now
									};
	var channelFactory = new ChannelFactory<IDataService>("*");
	var dataService = channelFactory.CreateChannel();
	var asyncResult = dataService.BeginSaveInfonMachineActiveDefinition(newInfonMachineActiveDefinition, null, null);
	try
	{
		newInfonMachineActiveDefinition.Id = dataService.EndSaveInfonMachineActiveDefinition(asyncResult);
	}
	catch (Exception ex)
	{
		System.Diagnostics.Debug.WriteLine(ex.ToString());
	}
	if (Dispatcher.CheckAccess())
	{
		Visibility = Visibility.Collapsed;
		if (NewInfonMachineActiveDefinitionSaved != null)
			NewInfonMachineActiveDefinitionSaved(this, newInfonMachineActiveDefinition);
	}
	else
		Dispatcher.BeginInvoke(delegate
					{
						Visibility = Visibility.Collapsed;
						if (NewInfonMachineActiveDefinitionSaved != null)
							NewInfonMachineActiveDefinitionSaved(this, newInfonMachineActiveDefinition);
					});
});


____________________________________________________________
Be brave little warrior, be VERY brave

GeneralRe: Displaying Data fetched asyncronously Pin
Michael Sync23-Jul-09 7:03
Michael Sync23-Jul-09 7:03 
GeneralRe: Displaying Data fetched asyncronously Pin
Adriaan Davel23-Jul-09 19:52
Adriaan Davel23-Jul-09 19:52 
GeneralRe: Displaying Data fetched asyncronously Pin
Michael Sync23-Jul-09 20:11
Michael Sync23-Jul-09 20:11 
GeneralRe: Displaying Data fetched asyncronously Pin
Adriaan Davel23-Jul-09 21:32
Adriaan Davel23-Jul-09 21:32 
GeneralRe: Displaying Data fetched asyncronously Pin
Michael Sync24-Jul-09 2:23
Michael Sync24-Jul-09 2:23 
GeneralRe: Displaying Data fetched asyncronously Pin
Jeremy Likness26-Jul-09 3:17
professionalJeremy Likness26-Jul-09 3:17 
GeneralRe: Displaying Data fetched asyncronously Pin
Adriaan Davel27-Jul-09 1:42
Adriaan Davel27-Jul-09 1:42 
AnswerRe: Displaying Data fetched asyncronously Pin
Daniel Vaughan9-Jan-10 7:33
Daniel Vaughan9-Jan-10 7:33 
QuestionWPF TreeListView Control Not Working!!!!! Pin
ub3rst4r11-Jul-09 15:01
ub3rst4r11-Jul-09 15:01 
AnswerRe: WPF TreeListView Control Not Working!!!!! Pin
Christian Graus13-Jul-09 7:33
protectorChristian Graus13-Jul-09 7:33 
GeneralRe: WPF TreeListView Control Not Working!!!!! Pin
ub3rst4r13-Jul-09 8:24
ub3rst4r13-Jul-09 8:24 
GeneralRe: WPF TreeListView Control Not Working!!!!! Pin
Christian Graus13-Jul-09 8:42
protectorChristian Graus13-Jul-09 8:42 
QuestionDid you ever wonder, What the origin of XAML is? [modified] Pin
ProtoBytes10-Jul-09 10:29
ProtoBytes10-Jul-09 10:29 
AnswerRe: Did you ever wonder, What the origin of XAML is? Pin
Christian Graus11-Jul-09 4:39
protectorChristian Graus11-Jul-09 4:39 
GeneralRe: Did you ever wonder, What the origin of XAML is? Pin
ProtoBytes12-Jul-09 1:53
ProtoBytes12-Jul-09 1:53 
GeneralRe: Did you ever wonder, What the origin of XAML is? Pin
Christian Graus12-Jul-09 4:37
protectorChristian Graus12-Jul-09 4:37 
GeneralRe: Did you ever wonder, What the origin of XAML is? Pin
ProtoBytes12-Jul-09 6:00
ProtoBytes12-Jul-09 6:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.