使用信号量实现条件变量过程中的一些坑

https://birrell.org/andrew/papers/ImplementingCVs.pdf

另外,C#的Monitor.WaitMonitor.Pulse看起来可以用来实现CV。在这篇文章中提到了一些使用细节。看起来和pthread_cond_wait() 的用法有点类似,都要在函数返回后重新确认producer有没有产生需要的内容,然后在必要时继续等待。

值得一提的是,在第二篇文章中,作者实际上构造出了一个简易的AutoResetEvent 。

如何在PowerPoint中取消选择选区中的文本框

Sub UnselectTextBoxes()
Dim c As New Collection
For Each s In ActiveWindow.Selection.ShapeRange
    If s.TextFrame.HasText <> msoTrue Then
        c.Add s
    End If
Next
ActiveWindow.Selection.Unselect
For Each s In c
    s.Select MsoTriState.msoFalse
Next
End Sub

 

LINQ to SQL 中 Xml (XElement) 字段的常见问题

cite=LINQ to SQL FAQ – XML columns in SQL

LINQ to SQL 目前不支持包含 XElement 查询的 Expression 对象

However, LINQ to SQL does not appear to support ANY translations of XML queries on XElement to SQL – this mans that the following statement :

var filtered = from t in Table
where t.XmlCol.Descendants("SomeElement").Value == somevar
 select t

will fail at runtime as the LINQ-to-SQL parser is unable to translate on our XML data column XmlCol query into an Xpath.

LINQ to SQL 目前不支持由 XElement 内部变化引起的记录更新

A LINQ to SQL xml datatype column is represented as an XElement. If you modify this be careful as LINQ to SQL will not spot internal changes to XElement and save them to the database.

For example:

Dim myElement as XElement = Table.XMLdata
myElement.Value = "test"
db.SubmitChanges()

will not alter the instance XElement and so will not change the Table.XMLdata entry. The workaround for this is to write it back as a new element:

Dim myElement as XElement = Table.XMLdata
myElement.Value = "test"
Table.XMLdata = new XElement(myElement)
db.SubmitChanges()

 

Content is available under CC BY-SA 3.0 unless otherwise noted.