« first day (650 days earlier)      last day (3499 days later) » 

7:00 PM
I think it's something in this code
 
yeah its the progress ring you are doing
silly behavior
 
how do I remove that default progress ring?
I want to keep the bigger busy indicator
but not the small default one
I
I'm not sure what I'm supposed to look for in that code
to remove it
 
private void Start()
{
Mouse.OverrideCursor = Cursors.Wait;
animationTimer.Tick += HandleAnimationTick;
animationTimer.Start();
}
 
you are right
but if I comment that out
I need to comment out
HandleVisibleChanged
and that does not make the progress bar spin
 
just remove the Mouse.OverrideCursor bit
you still need the rest
 
7:07 PM
actually I realized (possibly?) bigger problem
the application hangs
before the method is called
 
look at my example
it is doing exactly what you are trying to do
without any of the crap around it
 
what's your example again?
 
thanks
but I have something to say about what I'm doing
um
I just realized if I insert a cd and click on my button to check cd drives
the application hangs anyway
before the method is called
the progress bar works fine when the method is called
but before then
 
your application will hang when you are doing work on the main thread
 
7:11 PM
the application hangs until the cd is read
 
you need to figure out what you are doing onthe main thread
 
can you give me an example of what you mean?
What I mean in detail is
if the cd is already insert, the progress bar works and everything works fine
 
the specifics of a cd or no cd does not matter
 
but if the user inserts the cd the same time as clicking the button, the application hangs
really?
hmm
 
if your application is hanging
you are doing work on the main thread
 
7:13 PM
it's hanging for a second
like the cursor shows a default cd picture next to it
then hangs
before even the command is called I think
 
try commenting out all the code of your button
and see if it still hangs
 
ok
comment out the xaml binding?
 
no, the code behind for the button
 
you mean the stuff in my viewmodel?
 
yes
 
7:17 PM
if I comment out both my command
and async method
you're right
it's not the cd
weird
hmm
 
the button press code behind happens on the main thread
so any work you want to do you need to split off to a task or thread or background worker
immediately
 
I thought I was doing that
in dosomethingasync()
 
lets see your button press code behind
 
private void PerformCDDetection()
{
//Gets all the drives
DriveInfo[] allDrives = DriveInfo.GetDrives();

//checks if any CD-Rom exists in the drives
var cdRomExists = allDrives.Any(x => x.DriveType == DriveType.CDRom);

// Get all the cd roms
var cdRoms = allDrives.Where(x => x.DriveType == DriveType.CDRom && allDrives.Any(y => y.IsReady));

if (cdRomExists.Equals(true))
{
// Loop through the cd roms collection
foreach(var cdRom in cdRoms)
{
Console.WriteLine("Drive {0}", cdRom.Name);
Console.WriteLine(" File type: {0}", cdRom.DriveType);
 
that is your button press code behind??
there is no async there at all
 
7:22 PM
private async Task DoSomethingAsync() {

ProgressBarVisibility = Visibility.Visible;
await Task.Factory.StartNew(() => { PerformCDDetection(); });
ProgressBarVisibility = Visibility.Collapsed;
}
that
That's the async method that calls the other method
 
ok. but when you press the button
what is the first thing called
do you have a click event on the button
or a command
 
just command
 
and what function is the command calling
 
public ICommand ImportFilePathCommand
{
get
{
return new RelayCommand(async () => { await DoSomethingAsync(); });
}

}
 
ok
 
7:23 PM
calling DoSomethingAsync()
 
so you have a button press going into code behind on the main thread
and then you are telling it to wait for the new thread that is DoSomethingAsync to finish
so essentially you are not doing anything in the background
since the main thread is now awaiting your async method
i havent tried to call async methods off commands
 
any math-y type who can tell me why this function I found for determine the compass direction from 1 point to a 2nd is off by 90 degrees? i.e a point to the east comes up as north. And what the right fix is? I don't want to just add 2 to the index to compensate for bad math
public Directions DirectionTo(Coord to)
{
double radians = Math.Atan2((to.Y - Y), (to.X - X));

double compassReading = radians*(180/Math.PI);

Directions[] coordNames =
{
Directions.North, Directions.NorthEast, Directions.East, Directions.SouthEast,
Directions.South, Directions.SouthWest, Directions.West, Directions.NorthWest, Directions.North,
};
double coordIndex = Math.Round(compassReading/45);
if (coordIndex < 0)
{
coordIndex = coordIndex + 8;
}


return coordNames[(int) coordIndex]; // returns the coordinate value
 
@KalaJ the first thing i would do is make the method that your command is calling a normal method. no async
then remove the await from await Task.Factory.StartNew(() => { PerformCDDetection(); });
 
user3010322
@DreadPiratePeter 1. Use Radians, not degrees, until it's time to display something to the UI.
 
@Julien private Task DoSomethingAsync() {

ProgressBarVisibility = Visibility.Visible;
Task.Factory.StartNew(() => { PerformCDDetection(); });
ProgressBarVisibility = Visibility.Collapsed;
}
like this?
 
7:27 PM
yes. now one more thing
 
ok
 
because your PerformCDDetection is a task
your ProgressBarVis var will go to visible then collapsed immediately
 
user3010322
@DreadPiratePeter 2. Use flag values and then just do numeric comparisons to fill in the flags.
 
because your DoSomethingAsync is not going to wait for PerformCDDetection to finish
so what you want is a ContinueWith on your task, so that you set collapsed only when Perform is finished
 
one more thing
DoSomethingAsync()': not all code paths return a value
and I can't make it void
 
7:29 PM
just return new Task
 
because there's a task
return new Task();?
 
i think you can actually do just plain return;
 
user3010322
[Flags()]
public enum Directions {
     Nowhere = 0x0
     North = 0x01,
     South = 0x02,
     East = 0x04,
    West = 0x08
     NorthEast = North | East,
     NorthWest = North | West,
     SouthWest = South | West,
     SouthEast = South | East
}
 
Task.Factory.StartNew(() => Console.WriteLine("doing work")).ContinueWith(t => Console.WriteLine("all done"));
there is the continue with
 
user3010322
TThen...
 
7:31 PM
can't return
An object of a type convertible to 'System.Threading.Tasks.Task' is required
with just return;
 
user3010322
Directions dir = Directions.Nowhere;
if ( X < to.X )
     dir |= Directions.East;
else if ( X > to.X )
     dir |= Directions.West;
if ( Y < to.Y )
     dir |= Directions.North;
else if ( Y > to.Y )
     dir |= Directions.South;
 
user3010322
@DreadPiratePeter ^
 
@ThePhD this is pretty nice for flag enums. Especially if you have a bunch.
 
the async method is so unnecessary. just kill it :D
 
tell me about it
yeah I can't return new Task or just return or even return new Task()
 
7:39 PM
changed it to use a Command
 
user3010322
@JohanLarsson That does look nice.
 
Tastes like metal to be shifting like that :)
 
changed to a command but ..?
what can I do with the task?
 
all your work
 
lol
 
7:46 PM
everything you want the button press to do but not lock the GUI should go into the task
 
lol
 
kala wants to show a dialog in the task
 
no, not anymore
 
yeah not anymore
Everything I want to do should be inside right now
but it still hangs
using await/async
 
comment out code until it stops hanging
then you will know what is causing it
 
7:48 PM
i don't see any await/async in Julien's code
 
it's in my code
I'll make a github and post it
but basically this is my async method
private async Task DoSomethingAsync() {

ProgressBarVisibility = Visibility.Visible;

await Task.Factory.StartNew(() => { PerformCDDetection(); }).ContinueWith(t => { ProgressBarVisibility = Visibility.Collapsed; });
}
 
forget the async method
that is so opintless
 
you can just use gist.github.com
 
you have an async method waiting for an async method
that makes no sense
your command is awaiting DoSomethingAsync which is awaiting PerformCDDetection
and since your command is on the main thread
all you are doing is waiting
 
get rid of that whole thing and call PerformCDDetection() where Thread.Sleep is in Juliens code
 
await means wait for whatever comes next to finish
 
It gives me errors if I don't use await/async
 
look at my example
it has no async
and no errors
 
i'm done here
 
please, please, please start a new project
that does nothing except animate a progress bar
 
7:52 PM
oh let me try something
 
because you are missing some basic elements here
and your own code is confusing you
 
private void DoSomethingAsync() {

ProgressBarVisibility = Visibility.Visible;
// await Task.Factory.StartNew(() => { PerformCDDetection(); });
Task.Factory.StartNew(() => { PerformCDDetection(); }).ContinueWith(t => { ProgressBarVisibility = Visibility.Collapsed; });
}
 
you are in an async method
 
public ICommand ImportFilePathCommand
{
get
{
return new RelayCommand(() => { DoSomethingAsync(); });
}

}
 
calling another async function. that makes no sense
oh, you removed thea sync
 
7:53 PM
no more async
 
ok yes that makes more sense
 
still hangs
lol
 
load my example
 
I'm sure it works
lol
 
so copy it
 
7:58 PM
wait what object are you passing
 
im not passing anything
 
(object o)
 
that is just how my RelayCommand is implemented
if i was setting CommandParameter on the button it would come through o
 
ohh ok
 
in this case o would just be null
 
8:02 PM
your example seems fine
I made mine similar to yours
and still hangs
might have to take a break and come back to it
 
:) start commenting out code until it stops hanging
 
might be something in my method
but yeah lol
 
as long as your method is called within the task
it should not lock the gui
 
@KalaJ does your mouse freeze too?
 
What about Task.Run?
yeah it does
I mean no
sorry
my mouse cursor does not freeze
 
8:10 PM
what is "hanging"
 
the animation
for the progress bar
is frozen
 
progress bar? how is it frozen?
 
it does not spin
the busy indicator* does not spin
 
like, a literal progress bar?
 
or animate
 
8:11 PM
can you link the control that you're using?
 
no custom busy indicator
 
did you bind DoingWork to it?
 
no
only Visibility="{Binding ProgressBarVisibility}
 
it shows up and goes away but doesn't spin?
 
do I need DoingWork?
it show up
but it just says
and does not spin
or animate
just frozen
in the view
until the ened
 
8:15 PM
if you're using Juliens example, you have to replace that with Visibility="{Binding DoingWork, Converter={StaticResource BooleanToVisibilityConverter}}"
if you comment out all the code in PerformCDDetection does it still "hang"
 
no I mean in my example
not his example
ohhhhh
you are right
something wrong with the animation
it used to animate
now it's still stuck
even if I
comment this out: Task.Run(delegate { PerformCDDetection(); }).ContinueWith(t => { ProgressBarVisibility = Visibility.Collapsed; });
 
check your output window for any errors
 
wow thank you guys
it works LOL
I changed something in my xaml and I forgot to change it back
@Julien @NETscape Thank you
 
8:46 PM
@ReedCopsey basically what I was wanting to do was instead of the (!) showing up during an error, have a textbox with the validationerror popup so the user doesn't have to mouse over
C# doesn't seem to have that "EntityErrors"
 
so my arrow code is not working as well as I initially thought. here is the problem. since the animation is async (to get it to actually render), while it is going on my event loop is continuing, so often the creature you are shooting at moves during the animation, so the arrow goes to the empty square he was in
what I really need is a synchronous way of running the animation, so that things wait for it to finish, but I see no mvvm friendly way of telling the ui to update synchronously
 
that's a miss then, right?!
aim better ;)
 
Is there an MVVM-friendly way to cause a ui update?
 
NotifyPropertyChanged("____")? :)
 
that won't cause an update until control goes back to the ui, at least that's the behavior I am seeing
and by that time my arrow is long since gone
 
9:01 PM
calculate where the creature will be by the time the arrow gets to the end of its path
then make that your arrows endposition, then start the animation
 
@NETscape Nope - that's part of my stuff
but you can have anything with an errors collection
 
1. I can't. the creature hasn't even decided where to move next when I am doing the animation. 2. I don't want to, as the arrow should have already animated. Roguelikes are turn based
 
@ReedCopsey right but what I'm trying to do is something like <Setter Property="ToolTipService.ToolTip"> but instead of it being a tooltip, have it being a popup
 
you'd have to bind the popup IsOpen to something that triggers when it exists
 
would i have to edit the template of textbox to have another control that is shown when haserrors = true
 
9:24 PM
well, or have the error template do an adorner for it or something - doesn't really need a textbox, right?
(can't edit the error...)
 
0
Q: CollectionView with Expander not finding property although works outside of expander header

BoardyI am working on a C# WPF project and I am trying to using a CollectionView to group elements together. The data is read in via an XML message stored within an array. Below is the code I am using to process the array: public void processCallLogInfo(string xml) { List<CallL...

 
10:04 PM
which is what I tried, but the adorner's datacontext isn't going to be = to that of TextBox @ReedCopsey
 
10:34 PM
@NETscape You can force it by binding the child of the adorner's DataContext with an elementname binding, though, IIRC - pain/stupid, but works
 
I said screw it until a later time... grrrr
was going to do it all in the VM and have no validation but my patience wore thin
 

« first day (650 days earlier)      last day (3499 days later) »