I’m trying to get some projects from the “Concurrency in .NET” book by Riccardo Terrell working but the downloaded projects cause so many build errors that are incomprehensible to me that I’m trying to create my own projects from scratch and copy the necessary code into them.
The code contains things such as:
open System.Windows
open System.Threading
open System.Windows.Threading
...
let form = Window(Content=image, Title="Game of Life", Width=800., Height=823.)
let application = new Application()
…and:
open System.Windows
open System.Windows.Media
open System.Windows.Media.Imaging
open System.Threading
...
let createImage (grid:Grid) (pixels:Array) =
BitmapSource.Create(grid.Width, grid.Height, 96., 96., PixelFormats.Gray8, null, pixels, grid.Width)
…but I don’t know what sort of project to create (I’m using Visual Studio), or which NuGet packages to use, or how to reference the correct things, or how to configure things to get the code working.
Can anyone help?
(I found a thread in the forums about using this sort of thing in a script but I don’t know if any of that is relevant to what I’m trying to do.)
I don’t have a great answer, but I looked up the System.Windows.Threading namespace and it started talking about a bunch of WPF stuff. I looked up WPF and found this guide on creating a new project. I don’t use Visual Studio, so I did a dotnet new list and saw
so no F# support .
I can create a new C# project and look in the csproj file to see how it’s setup:
Hopefully it would work if you copied those same things into your F# project?
That said, I think WPF is a very C#-y way of handling UI. I haven’t built any UIs in F#, but I’ve heard good things about Fabulous, so that might be worth looking into. I’m guessing it’s a little bit smoother experience than trying to get WPF working on F#.
(The stuff in the ItemGroup should be the FS files in the project, not just these specific items.)
Thanks again for your, as ever, valuable help.
P.S. I’ll try to remember looking at Fabulous later, it would be great to get the UI done in F# without resorting to C#, but at the moment I’m just trying to do the stuff in the book I’m reading.